what was the earliest version of perl that would
allow you to use scalar filehandles?
open(my $fh, filename);
instead of
open(FILEHANDLE, filename);
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm
more importantly, what is the syntax for passing a filehandle
into a routine if it is FILEHANDLE instead of $FILEHANDLE?
From: [EMAIL PROTECTED] on behalf of Greg London
Sent: Tue 5/23/2006 4:10 PM
To: boston-pm@mail.pm.org
Subject: [Boston.pm] version of perl
more importantly, what is the syntax for passing a filehandle
into a routine if it is FILEHANDLE instead of $FILEHANDLE?
open(FILEHANDLE, $filename ) or die trying $!;
open(my $fh, filename);
Autovivification of unitialized scalar filehandles was added in 5.6.0
On Tue, 23 May 2006 16:10:40 -0400, Greg London said:
what was the earliest version of perl that would allow you to use
scalar filehandles?
5.6; see perldoc perl56delta, File and directory handles can be
autovivified.
more importantly, what is the syntax for passing a filehandle
more importantly, what is the syntax for passing a filehandle
into a routine if it is FILEHANDLE instead of $FILEHANDLE?
foo(*FILEHANDLE)
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm
Use scalar filehandles? You're probably thinking of 5.6.0, which was
the first that would let you autovivify filehandles. As far as I
know, through the 5.x series you could always do:
my $fh = do {local *fh};
open($fh, $somefile) or die Can't read '$somefile': $!;
If you didn't remember
5.6?
(weeps)
well, that'll never happen.
I'll have to recode with *GLOBS.
(weeps some more)
Thanks for all the replies.
Greg
From: Ricker, William [mailto:[EMAIL PROTECTED]
Sent: Tue 5/23/2006 4:23 PM
To: Greg London
Cc: boston-pm@mail.pm.org
Subject:
Do not weep.
What changed in 5.6 was that it started autovivifying them. Just make
the following conversion:
open(my $fh, $file) ...
my $fh = do {local *FH};
open($fh, $file) ...
and your problem is fixed.
Cheers,
Ben
On 5/23/06, Greg London [EMAIL PROTECTED] wrote:
5.6?
(weeps)
BT == Ben Tilly [EMAIL PROTECTED] writes:
BT If you didn't remember the do local trick, you could always use Symbol
BT and then call gensym to get your typeglob.
i have used Symbol::gensym for years and it is fine for this. it comes
with perl5 from way back before 5.6 (not sure how old it
On 5/23/06, Uri Guttman [EMAIL PROTECTED] wrote:
BT == Ben Tilly [EMAIL PROTECTED] writes:
BT If you didn't remember the do local trick, you could always use Symbol
BT and then call gensym to get your typeglob.
i have used Symbol::gensym for years and it is fine for this. it comes
with
Note that 5.6 says *auto-vivification*, you could actually use scalar file
handles prior to this but you had to use Symbol::gensym (which is the proper
way to do the work-around given).
perl -MModule::CoreList -e 'print Module::CoreList-first_release('Symbol');'
prints 5.002
--
11 matches
Mail list logo