in reply to Save/restore STDIN

It may be simpler to just localize *STDIN,

{ open local(*STDIN), '<', "whatever" or die $!; # go on with processing, # calls to any sub will think STDIN is # the one you just set up. # ... close STDIN or die $!; } # old STDIN is restored, never been touched.
Explicit duplication is sometimes necessary, but not usually.

After Compline,
Zaxo