in reply to How to tie a lexical filehandle.
use IO::Handle; my $fh = IO::Handle->new; tie *$fh, ...;
Update: Or the following slightly more low-level way, the relevant code of IO::Handle->new doesn't do a whole lot more than this:
use Symbol qw/gensym/; my $fh = gensym; tie *$fh, ...;
Links: IO::Handle, Symbol.
Update 2017-09-30: One more, from here:
my $fh = \do { local *HANDLE };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to tie a lexical filehandle.
by clueless newbie (Curate) on Jun 20, 2017 at 21:31 UTC |