Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Search between two words in a file

by matija (Priest)
on Jun 14, 2004 at 10:32 UTC ( #366481=note: print w/ replies, xml ) Need Help??


in reply to Search between two words in a file

One way would be to read each paragraph into a single variable (either by setting $/ or by appending line to the variable until you get to the end of the paragraph), then simply match using something like $paragraph=~/FROM(something wild)WHERE/;


Comment on Re: Search between two words in a file
Download Code
Replies are listed 'Best First'.
Re^2: Search between two words in a file
by Happy-the-monk (Abbot) on Jun 14, 2004 at 11:58 UTC

    To the Original Poster:
    The manuals   perldoc perlrequick   and   perldoc perlre   describe it quite well.

    You will understand matija's solution after a quick glance into one of them and be able to use it.

    $paragraph =~ m/FROM(.*?)WHERE/; # now everything in between is in   $1
    my $inbetween = $1;

    If that still doesn't make much sense, everything else can be found in   perldoc perlintro.

    Cheers, Sören

Re^2: Search between two words in a file
by Anonymous Monk on Jun 15, 2004 at 05:51 UTC
    can you give me the command used for appending line to a variable until end of line. and after matching the data using "$paragraph=~/FROM(something wild)WHERE/;", how can I print that variable?
Re^2: Search between two words in a file
by Anonymous Monk on Jun 14, 2004 at 11:49 UTC
    Can u just send me the script as i am totally new to perl scripting and i have been assigned this task to do.
      Can "u" just send us your next paycheck?

      --
      [ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://366481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2015-07-29 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls