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

> THe problem with that is, that when perl reads my file
> which was created on windows, it treats the whole file as one line

that's odd. most MSDOS/Windows files use CR/LF as the end-of-line marker, but it sounds like your file uses just CR...are you sure it's a DOS file and not a Mac file?

to read MSDOS/Windows text files, you need to set the input record separator to CR/LF rather than newline (actually, this isn't strictly necessary. if you don't do it, you just end up with a CR at the end of each line. chomp will get rid of it)

i.e.

$/="\r\n";

to read Mac text files, set it to just CR:

$/="\r";

see the man page for 'perlvar' for more info.

  • Comment on Re^3: Matching string, then getting next line