Operating System - HP-UX
1833012 Members
3197 Online
110048 Solutions
New Discussion

perl in place edit question

 
Ian McClement_1
Occasional Advisor

perl in place edit question

Hi
I am using the perl "in place edit" function
ie. perl -i -p -e's/string1/string2/g' filenam

is it possible to pass in a sed file - equivalent of sed -f with multiple search and replaces ?
Cannot see it in the help "stuff"

Cheers
Ian
2 REPLIES 2
Ralph Grothe
Honored Contributor

Re: perl in place edit question

If you need more parsing to be done than what is comfortable on a single line just write a Perl script.
You may always invoke by separately calling for the perl with any number of switches.

Besides, you can separate single Perl statements by semicolons in your -e string.

Have a look at

perldoc perlrun
Madness, thy name is system administration
H.Merijn Brand (procura
Honored Contributor

Re: perl in place edit question

Like this?

l1:/tmp 104 > cat xx.txt
abcdef
bcdefg
cdefgh
defghi
efghij
l1:/tmp 105 > cat xx.pl
#!/pro/bin/perl -pi

s/a/AHA/g;
tr/b/X/;
s/fg/GF/;
l1:/tmp 106 > perl xx.pl xx.txt
l1:/tmp 107 > cat xx.txt
AHAXcdef
XcdeGF
cdeGFh
deGFhi
eGFhij
l1:/tmp 108 >

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn