in reply to Check for "unix2dos" (CRLF) in binary files
#!/usr/bin/perl use strict; use warnings; for my $file ( @ARGV ) { my ( $lf, $crlf ) = ( 0 ) x 2; open my $fh, '<', $file or die "open $file: $!\n"; local $_ = " "; while ( read $fh, $_, 65536, 1 ) { $lf += @{ [ /(?<!\x0d)\x0a(?!\x0d)/g ] }; $ctlf += @{ [ /\x0a\x0d/g, /\x0d\x0a/g ] }; $_ = chop; } print "$file: $lf LF, $crlf CRLF\n"; }
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check for "unix2dos" (CRLF) in binary files
by graff (Chancellor) on Sep 17, 2004 at 07:34 UTC | |
by Aristotle (Chancellor) on Sep 17, 2004 at 07:55 UTC | |
by jfroebe (Parson) on Sep 23, 2004 at 16:16 UTC | |
by graff (Chancellor) on Sep 24, 2004 at 02:33 UTC |