in reply to Re: Re^6: Determining what line a filehandle is on
in thread Determining what line a filehandle is on

I believe this was introduced in Perl 5, so your definition of "new" is obviously a matter of perspective.

In fact, one of the things that I'm wondering is if you are supposed to be using "old-fashioned" file handles at all. They are more difficult to localize and pass as parameters. Using a "GLOB-ref", as these file handles are, is much more convenient, given even the one-character "penalty" for the $.

Update:
The "traditional" way is along the lines of:
local (*FOO); open (FOO, $foo_file) || die "Could not open $foo_file\n"; DoStuffOnHandle(\*FOO); close (FOO);
Versus the new "lexical" way:
my $foo; open ($foo, $foo_file) || die "Could not open $foo_file\n"; DoStuffOnHandle($foo); close ($foo);

Replies are listed 'Best First'.
Re (tilly) 9: Determining what line a filehandle is on
by tilly (Archbishop) on Jul 09, 2001 at 16:34 UTC
    Actually this was introduced in 5.6.0, so new really isn't that relative. In 5.005_03 and earlier you have to jump an extra hoop:
    my $foo = do {local *FH}; # etc as above
    or if you prefer a different look, you can use Symbol and then do it with:
    my $foo = gensym(); # And so on
    But with 5.6 it autovivifies for you, and that is rather nice.
Re: Re^8: Determining what line a filehandle is on
by John M. Dlugosz (Monsignor) on Jul 09, 2001 at 07:08 UTC
    Well, that convinces me. Since there is no real issue, I'll use lexical variables going forward.