in reply to How to replace a piece of text containing brackets in an external file

my $filename = '/tmp/somefile.html'; my $find = quotemeta "<option SELECTED>[ Current time range ]"; my $replace = '<option SELECTED> Current time'; { local @ARGV = ($filename); local $^I = '.bac'; while( <> ){ if( s/$find/$replace/ig ) { print; } else { print; } } }

Or, with a saner while loop...

my $filename = '/tmp/somefile.html'; my $find = quotemeta "<option SELECTED>[ Current time range ]"; my $replace = '<option SELECTED> Current time'; { local @ARGV = ($filename); local $^I = '.bac'; while( <> ){ s/$find/$replace/ig; print; } }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'