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);
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.