http://qs1969.pair.com?node_id=597951


in reply to -pi -e argv repeater

Perhaps you'd like

use constant PIE_NO_BACKUP => ''; sub pie(&$@) { ( my $code, # Code ref local $^I, # PIE_NO_BACKUP, '~', '.bak', etc local @ARGV, ) = @_; local *_; # Protect caller's $_. while (<>) { chomp; $code->(); print($_, "\n"); } } # perl -i -pe 's///' file1 file2 pie { s/// } PIE_NO_BACKUP, 'file1', 'file2'; # perl -i.bak -pe 's///' file? data*.txt pie { s/// } '.bak', map { bsd_glob($_) } 'file?', 'data*.txt';

Untested.

Update: Added missing "\n". Created constant for no backup. Added local *_;.