option_replacement( "tar=s", sub { system "tar xf $_[1] -C $tmpdir"; "$tmpdir/*" } ); #### use Getopt::Long; sub option_replacement { my( $spec, $func ) = @_; local $Getopt::Long::passthrough=1; my @newARGV; GetOptions( $spec => sub { push @newARGV, &$func }, '<>' => sub { push @newARGV, @_ }, ); @ARGV = @newARGV; }