in reply to Determine whether file is dos or unix format
Rather than just die()ing, you could auto convert the file to the native format on load. That's something I do often in my scripts where I could be recieving files in DOS, Unix or Mac format.
open my $fh, '<', $filename or die "Can't open file. $!\n"; while (<$fh>){ $_ =~ s/\cM\cJ|\cM|\cJ/\n/g; # do somthing with line }
Yeah, it does useless conversions on native format files, but the overhead is nearly negligible usually.
|
|---|