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

Re^7: Matching string, then getting next line

by wazoox (Prior)
on Mar 08, 2006 at 15:13 UTC ( #535184=note: print w/replies, xml ) Need Help??


in reply to Re^6: Matching string, then getting next line
in thread Matching string, then getting next line

You can try to change the line separator $/ to "Message Dump:", then each line would end with "Message Dump:". However the conversion from DOS to Unix line ends is more standard and reusable...
my @messages; my $inmessage = 0; # 0 false, 1 true while ( <FILE> ) { s/\r\n$/\n/ ; if ( $inmessage) { push $_, @messages; } if ( m/Message Dump:.*/ ) { # we set $inmessage to 1 if 0, or 0 if 1 $inmessage = abs( $inmessage -1 ) ; }

Replies are listed 'Best First'.
Re^8: Matching string, then getting next line
by minixman (Beadle) on Mar 09, 2006 at 08:15 UTC
    Not sure this is going to work, as it will never find the message i am looking for, should i not be using something like the (.*) so store the contents between Message Dump: and Message Dump:
      Well if you know what's you're looking for, probably matching it directly would be easier then.
      my $message; while (<FILE>) { if ( m/\d\d \d\d\/\d\d\/\d\d \d\d:\d\d:\d\d:\d\d\d .*/ ) { $message .= $_ } }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2019-09-17 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (199 votes). Check out past polls.

    Notices?