http://www.perlmonks.org?node_id=485829


in reply to Compact multi-line inplace file edit search and replace

Very creative!

But I guess that you also need to list the last part of the file.

That is, like in a huge

split
, ain't me right? It looks good for raw XML replacements :) .

(updated)

Sorry, I still can't get what the my $matched= chomp; really does... I need more practice, I guess [-(.

{ \ ( ' v ' ) / }
( \ _ / ) _ _ _ _ ` ( ) ' _ _ _ _
( = ( ^ Y ^ ) = ( _ _ ^ ^ ^ ^
_ _ _ _ \ _ ( m _ _ _ m ) _ _ _ _ _ _ _ _ _ ) c h i a n o , a l b e r t o
Wherever I lay my KNOPPIX disk, a new FREE LINUX nation could be established

Replies are listed 'Best First'.
Re^2: Compact multi-line inplace file edit search and replace
by GrandFather (Saint) on Aug 23, 2005 at 07:40 UTC

    Actually you do get the last part of the source file. If there is just one instance of the match text in the original file then the first itteration of the loop prints the part before the match and the replacement text. The second itteration prints the part of the original file following the match text, but does not insert the replacement text.


    Perl is Huffman encoded by design.