ldbpm has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to parse a file similar to the following:
======================================================== Net Stuff ======================================================== slfjs sfafdds aslfkjsdl sfsdf ======================================================== Services ======================================================== blah glah sfsd asfsdf afsafdf ======================================================== Users ======================================================== Services sam bill frank
I am attempting to match between the first match of "Services", and not after, but I am getting everything using the following code:
while(<>) { if ( /^Services$/ .. /^Users$/ ) { print "$_"; } }
Even when I use multi-line match regular expression, I get the same output:
while(<>) { if ( /^=*Services$/m .. /^=*Users$/m ) { print "$_"; } }
Once again, I just want what is in between first occurrence of "Services" and "Users".
Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching ranges
by BrowserUk (Patriarch) on Sep 02, 2010 at 02:27 UTC | |
by ldbpm (Initiate) on Sep 02, 2010 at 02:54 UTC | |
|
Re: Matching ranges
by dasgar (Priest) on Sep 02, 2010 at 04:55 UTC | |
by ldbpm (Initiate) on Sep 02, 2010 at 12:15 UTC | |
|
Re: Matching ranges
by JavaFan (Canon) on Sep 02, 2010 at 10:08 UTC | |
by ldbpm (Initiate) on Sep 02, 2010 at 12:42 UTC | |
by Marshall (Canon) on Sep 02, 2010 at 14:24 UTC | |
by ldbpm (Initiate) on Sep 02, 2010 at 15:12 UTC | |
by Marshall (Canon) on Sep 02, 2010 at 14:34 UTC | |
by ldbpm (Initiate) on Sep 02, 2010 at 15:21 UTC | |
by ldbpm (Initiate) on Sep 02, 2010 at 12:02 UTC | |
|
Re: Matching ranges
by aquarium (Curate) on Sep 02, 2010 at 03:44 UTC | |
by aquarium (Curate) on Sep 02, 2010 at 04:07 UTC |