Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: regex file in-line

by Moron (Curate)
on Jun 13, 2007 at 09:38 UTC ( [id://620909]=note: print w/replies, xml ) Need Help??


in reply to regex file in-line

The problem is that although you perform the substitution in memory it doesn't get written to the output file. The easiest way to achieve that is to add the -a option, e.g.
alias mycmd="perl -p -i.out -w -ae 's/Fred/arry/g'"
to execute the pseudoscript...
mycmd myfile
See perlrun for the relevant docn. alias is a unix command, there is proabably a DOS equivalent.

Update: when I wrote this, perldoc was down. But I was able to test my suggestion. I started off with -lane instead of -ae and then narrowed it down, not having perlrun available in my head. But I really think the OP has enough from the perlrun link to solve the problem a la rtfm.

__________________________________________________________________________________

^M Free your mind!

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found