Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: perl -pi -e s'/^\s+//'g $file

by duelafn (Priest)
on Apr 08, 2011 at 02:57 UTC ( #898244=note: print w/ replies, xml ) Need Help??


in reply to perl -pi -e s'/^\s+//'g $file

That is why we have subroutines:

sub pie(&@) { my ($cb, $file) = @_; rename $file, "$file~" or die "Error backing up $file: $!"; open my $IN, "<", "$file~" or die "Error reading $file~: $!"; open my $OUT, ">", $file or die "Error writing $file: $!"; local $_; while (defined( $_ = <$IN> )) { $cb->(); print $OUT $_; } } pie { s/^\s+// } "myfile.txt";

Good Day,
    Dean


Comment on Re: perl -pi -e s'/^\s+//'g $file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://898244]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-10-31 15:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (219 votes), past polls