in reply to Re: Avoid re-invocation for -pie processing
in thread Avoid re-invocation for -pie processing

I sometimes use the following, which also resets *ARGV and $ARGV:

local *ARGV = [$path];

... but most of the time, I forget about the other slots...

Update: And I learned something. That stanza above does not reset $ARGV:

perl -wlE 'sub say_argv { say @ARGV, $ARGV; }; $ARGV=9; say_argv; do { + local *ARGV = ["foo"]; say_argv; }; say_argv' 1 2 3 1239 foo9 1239

Replies are listed 'Best First'.
Re^3: Avoid re-invocation for -pie processing
by ikegami (Patriarch) on Jan 10, 2024 at 14:24 UTC

    If you're not in the middle of using <> (since the snippet I posted doesn't work if you're already in the middle of reading from ARGV), then it doesn't really matter if you clobber *ARGV{IO} and $ARGV.