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

Re: find and replace in perl

by prashantktyagi (Scribe)
on Jun 24, 2013 at 05:46 UTC ( #1040363=note: print w/replies, xml ) Need Help??

in reply to find and replace in perl

$string =~ s/$pattern/$replace/g

Replies are listed 'Best First'.
Re^2: find and replace in perl
by torres09 (Acolyte) on Jun 24, 2013 at 06:15 UTC

    can't we do the find and replace operation via perl on the entire text file , without taking it into an array

    like say find and replace on a file handler . sorry I am new to perl , so I don't have a lot of command on it

      perl -pi.bak -e 's/pattern/replace/g' filename.txt


      sorry I am new to perl

      :) I read perlintro every day, and I'm very old to perl :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040363]
[1nickt]: Corion I feel that way a lot when I look at the news...
[1nickt]: Brethren, I just noticed in the CPAN ticker Retry, which led me to Attempt, by Mark Fowler. Does anyone have experience with either of these utilities?
[Corion]: No. Back when I toyed with the idea, I found that writing the loop explicitly was usually less code than passing the configuration+ callback to the retrier...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2017-05-24 12:30 GMT
Find Nodes?
    Voting Booth?