useful snippet for win32 users, converts line breaks from *nix to win32 via the @ARGV array, so it works via command line and drap & drop. if you know how, you can even put it in the right-click file context menu. you could also switch the chars for $r and $n and use it on *nix systems.
if(!@ARGV) {
print <<"EOC";
Usage: reformat.exe -b files
[-b] : include this flag if you would like to automatically
backup all files being reformatted
[files] : files to reformat
EOC
sleep;
}
@f = @ARGV;
if($ARGV[0] eq '-b') {
$b = 1;
shift(@ARGV);
} else {
$b = 0;
}
foreach $f (@f) {
$f =~ s/\\/\//g;
open(FILE,"$f");
@file = <FILE>;
close(FILE);
if($b) {
open(BKUP,">$f.bak");
foreach $i (@file) {print BKUP $i}
close(BKUP);
}
foreach (@file) {chomp}
$file = join("\n",@file);
$r = chr(13);
$n = chr(10);
$file =~ s/$r/$n/g;
open(FILE,">$f");
print FILE $file;
close(FILE);
}