Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: •Re: Large scale search and replace with perl -i

by BrowserUk (Patriarch)
on Apr 20, 2003 at 07:23 UTC ( [id://251785]=note: print w/replies, xml ) Need Help??


in reply to •Re: Large scale search and replace with perl -i
in thread Large scale search and replace with perl -i

One small caveat with this neat technique (that I just got bitten by) is that if $^I is set to a wild card (eg. *.bak or orig_*) so that the filename of the backup is edited rather than simply appended, the rename will fail.

I'll hazard a guess as to your respose to this as

<merlyn>Don't do that then. {grin}</merlyn>

but I thought it was worth a mention here :)


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.
  • Comment on Re: &bull;Re: Large scale search and replace with perl -i

Replies are listed 'Best First'.
•Re: Re: •Re: Large scale search and replace with perl -i
by merlyn (Sage) on Apr 20, 2003 at 15:37 UTC
    But, that star there doesn't do anything. That would create files named "foo*.bak" and "bar*.bak" from "foo" and "bar". And thus, the rename would undo it just fine.

    Unless you're talking about some local hack to your Perl to make it interpret $^I differently.

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

    update Oh my goodness. A new feature was snuck in to Perl in 5.6, and documented in perlrun but not perlvar.

    My apologies. Wow, I'll have to write a column about it now to remember it. {grin} And I don't recall it in the perldelta from 5.5 to 5.6, or perhaps I considered it un-noteworthy. Yeah, just checked, not in perldelta. No wonder I hadn't noticed it.

    update 2 On further research, 5.4 didn't have the feature, but 5.5 did. And yet it wasn't in 5.5's perldelta. That's why I missed it. I don't always diff the entire manpage set. {sigh} I rely on perldelta.

    update 3 See "Put your inplace-edit backup files into a subdir".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-19 06:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found