Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

•Re: Put your inplace-edit backup files into a subdir

by merlyn (Sage)
on Apr 21, 2003 at 06:08 UTC ( #251940=note: print w/replies, xml ) Need Help??


in reply to Put your inplace-edit backup files into a subdir

I've had more than one person write to me in the day since I posted this snippet to say "Randal, you forgot the -i! It's not an in-place edit without that!".

No, I didn't. Setting $^I is the programmatic equivalent to setting -i on the command-line.

Cool, eh?

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re: Put your inplace-edit backup files into a subdir

Replies are listed 'Best First'.
Re^2: Put your inplace-edit backup files into a subdir
by Aristotle (Chancellor) on Apr 21, 2003 at 12:05 UTC
    I was personally puzzled at what $^T is for a moment, though I knew about $^I. So the simple form would be
    mkdir bak/ ; perl -pi'bak/*' -e 's/foo/bar/g' file1 file2 file3 ...
    Or
    perl -pi'bak/*' -e 'BEGIN { mkdir($^I =~ m!(.*/)!) } s/foo/bar/g' file +1 file2 file3 ...
    Or maybe even
    perl -MFile::Path -pi'bak/*' -e 'BEGIN { mkpath [ $^I =~ m!(.*/)! ] } +s/foo/bar/g' file1 file2 file3 ...
    *grin*

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://251940]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2016-12-11 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (168 votes). Check out past polls.