Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: doing a search and replace on a large file

by graff (Chancellor)
on Apr 15, 2004 at 02:02 UTC ( #345280=note: print w/replies, xml ) Need Help??

in reply to doing a search and replace on a large file

Most of the solutions above are fine -- especially hardburn's one-liner (that one got my ++!) -- but folks who know about unix command-line tools know that this is usually just a job for the "grep" command:
grep 'pattern to be kept' old.file > new.file
Of course, perl offers so much that "grep" can't do: more powerful regexes, support for multiple character encodings, and liberation from the old "every record must be just one line of text" mind-set. How about a Perl version of grep?

Well, I'm sure I'm not the only who has done this -- I just couldn't stop myself... Here it is: grepp -- Perl version of grep (I wrote it a year or so ago, have been using it regularly on solaris, linux and macosx -- should work fine on ms-windows -- and finally got around to posting it here).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://345280]
[Eily]: or count the parentheses :)
[Discipulus]: stupid me! I had to stay at home and do not code with the flu..
[holli]: bacause it's a syntax error
[Discipulus]: yes sorry forget and forgive me
[Eily]: for what it's worth I didn't go for the brightest solution either
[Eily]: I tried print eval '2+1/3*(2+2/5))' or print $@
[Eily]: and therefore concluded that the eval did succeed because there was no printed error :P
[Eily]: stupid operator precedence :D

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-10-24 10:21 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (287 votes). Check out past polls.