Update: Use chomp per tye's suggestionmy $matchBlock = do {local $/ = ""; <DATA>}; $/ = $matchBlock; @ARGV = ("file_to_inplace_edit.txt"); $^I = '.bak'; while (<>) { my $matched = chomp; print $_; #print everything up to the block to be replaced print "This replaces the matchBlock text\n" if $matched; } __DATA__ match string goes here. As long as you like and spanning lines if you like, but it must match exactly the text to be replaced including the line end characters in the file to be edited must be standard for the OS.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |