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: RE: [Boston.pm] version of perl that can use scalar filehandles



> 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
   http://search.cpan.org/~nwclark/perl-5.8.8/pod/perl56delta.pod

<QUOTE>
File and directory handles can be autovivified

Similar to how constructs such as $x->[0] autovivify a reference, handle
constructors (open(), opendir(), pipe(), socketpair(), sysopen(),
socket(), and accept()) now autovivify a file or directory handle if the
handle passed to them is an uninitialized scalar variable. This allows
the constructs such as open(my $fh, ...) and open(local $fh,...) to be
used to create filehandles that will conveniently be closed
automatically when the scope ends, provided there are no other
references to them. This largely eliminates the need for typeglobs when
opening filehandles that must be passed around, as in the following
example:

  sub myopen {
        open my $fh, "@_"
             or die "Can't open '@_': $!";
        return $fh;
    }

    {
        my $f = myopen("</etc/motd");
        print <$f>;
        # $f implicitly closed here
    }

</QUOTE>

5.6.0 also added 3-arg open($fh, $mode, $filename) for better safety
against "injection" etc.

Which means 5.5.x was the version that couldn't.


-=- Bill

Not speaking for the Firm.


 
_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to