in reply to ?? Blazes under Linux; crawls under XP & Win2K...
Windows and UNIX have different style line endings. If you run this under Win32 but use a file with UNIX-style endings, the whole file will be slurped instead of processed line by line. Try this before opening your file:
use Getopt::Long; my $line_ending = "\012"; #unix style default GetOptions( 'windows' => sub { $line_ending = "\015\012" } ); local $/ = $line_ending;
This will cause your script to assume UNIX line endings, but if you pass the parameter --windows to the command line, it will then assume the file has Windows-style line endings.
You could autodetect this, too, but it involves opening the file and reading until you find one of those pairs, then resetting the filehandle. I know I've seen code for that on PerlMonks...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: ?? Blazes under Linux; crawls under XP & Win2K...
by ikegami (Patriarch) on Jan 10, 2006 at 14:23 UTC |