Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

csuhockey3's scratchpad

by csuhockey3 (Curate)
on Jun 01, 2004 at 20:17 UTC ( #358520=scratchpad: print w/replies, xml ) Need Help??

#!/usr/bin/perl -w # Usage: dos2unix <DIRECTORY> $directory = shift @ARGV; $directory = '.' unless $directory; chdir( $directory ) || die "Unable to enter directory '$directory'.\n$ +!\n"; @files = <*.data>; $| = 1; $linesFixed = 0; foreach( @files ) { print "$_\t"; open(INPUT, "<$_"); rename( $_, "$_.bak") || die "Unable to rename $_\n$!\n"; open(OUTPUT, ">$_"); while(<INPUT>) { if ( s/\r\n/\n/ ) { $linesFixed++; } print OUTPUT; } } continue { print "($linesFixed)\n"; $linesFixed = 0; close INPUT; close OUTPUT; }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2017-08-23 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (358 votes). Check out past polls.

    Notices?