Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by duelafn (Vicar)
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://898244]
help
Chatterbox?
[erix]: I guess I'll stare it down in the end but I'm already staring for a while... :)
[erix]: btw, I had a typo in there, so reload (if anyone is looking)

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2018-01-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (216 votes). Check out past polls.

    Notices?