Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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

by Anonymous Monk
on Apr 26, 2011 at 11:57 UTC ( #901327=note: print w/replies, xml ) Need Help??

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

FWIW, you probably want
local @ARGV = @_; use ARGV::readonly;
see ARGV::readonly, magic-diamond <> behavior -- WHAT?!

Replies are listed 'Best First'.
Re^4: perl -pi -e s'/^\s+//'g $file
by Anonymous Monk on Mar 22, 2012 at 10:55 UTC

    Actually you'd need

    local @ARGV = @_; require ARGV::readonly; ARGV::readonly->import; ## THIS!!!

    But if you're going to write all that, which might confuse some, you might as well just steal ARGV::readonly verbatim

    local @ARGV = @_; # Tom Christiansen in Message-ID: <24692.1217339882@chthon> # reccomends essentially the following: for (@ARGV){ s/^(\s+)/.\/$1/; # leading whitespace preserved s/^/< /; # force open for input $_.=qq/\0/; # trailing whitespace preserved & pipes forbidden };
Re^4: perl -pi -e s'/^\s+//'g $file
by Anonymous Monk on Nov 23, 2012 at 07:34 UTC

    Actually ARGV::readonly isn't needed with -i.orig (or -pi.orig) because perl does a stat first

    $ perl -pe 1 "echo shabba|" shabba $ perl -Tpe 1 "echo shabba|" Insecure $ENV{PATH} while running with -T switch. $ perl -Tpi.orig -e 1 "echo shabba|" Can't open echo shabba|: Invalid argument.

    Happens around

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-10-17 00:53 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (89 votes). Check out past polls.