in reply to RE: pointing a filehandle at a scalar or array ?
in thread pointing a filehandle at a scalar or array ?

When faced with this sort of problem, I've found it useful to just drop back one level of indirection and use subroutine references:

my $gimme = $fh ? sub { <$fh> } : sub { pop @array }; ... while (defined($x = &$gimme)) { ... }