in reply to Re^2: Matching string, then getting next line
in thread Matching string, then getting next line
I guess that you are trying this with a file that has been generated on Windows and then transferred to a UNIX box. You end up with extra ^M chars when you look at the file using vi. Try trimming the surplus whitespace using a regex
#!/usr/bin/perl -w use strict; while (<MYFILE>){ s/\s+$//; if (/NEXT LINE MARKER/) { my $nextLine = <MYFILE>; $nextLine =~ s/\s+$//; print "$nextLine\n"; # do stuff with the next line here. } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Matching string, then getting next line
by minixman (Beadle) on Mar 08, 2006 at 11:53 UTC | |
by wazoox (Prior) on Mar 08, 2006 at 13:05 UTC | |
by minixman (Beadle) on Mar 08, 2006 at 14:03 UTC | |
by wazoox (Prior) on Mar 08, 2006 at 15:13 UTC | |
by minixman (Beadle) on Mar 09, 2006 at 08:15 UTC | |
|
In Section
Seekers of Perl Wisdom