Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^5: Matching string, then getting next line

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

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

Actually you'd better remove only the ending "CR" characters, not spaces :
while (<MYFILE>) { s/\r\n$/\n/g; ... }
This simply replace "<CR><LF>" (DOS end of lines) with "<LF>" (Unix end of line)

Replies are listed 'Best First'.
Re^6: Matching string, then getting next line
by minixman (Beadle) on Mar 08, 2006 at 14:03 UTC
    Maybe a better option would be to try and split out everything between the message dump: and message dump: Is there a way to say something like
    if($_ =~ /Message Dump:(.*) Message Dump:/)
    And then the whole string would be in something like $1
      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 ) ; }
        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:

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2020-10-28 06:33 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (260 votes). Check out past polls.