you could read the first line of the file outside of the main loop (before entering the loop). Something like this:
It makes the program a bit more complicated, because you need to process the first line separately, but it might be worth it if your file is really large. If the file has a moderate size, I would probably not care about trying to be more efficient by checking only once the end-of-line characters.my $first_line = (<$IN>); my $endofline = $first_line =~ /\r\n$/ ? "\r\n" : "\n"; # process first line ... while (my $line = <$IN>) { # ... }
In reply to Re: Copying an ascii text file, replicating end of line terminator (windows or unix)
by Laurent_R
in thread Copying an ascii text file, replicating end of line terminator (windows or unix)
by luckycat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |