John W. Krahn wrote: > [EMAIL PROTECTED] wrote: >>Do either of you know if this second technique has the same small >>liability mentioned for the first one above: >>(From `perldoc -f fileno') >> >> `(Filehandles connected to memory objects via new features of >> "open" may return undefined even though they are open.)' > > Well, let's see what each one does: > > $ perl -e' > use Scalar::Util q/openhandle/; > my $var = "one\ntwo\nthree\nfour\n"; > open IN, "<", \$var or die $!; > print "fileno( IN ) is ", fileno( IN ) ? "" : "not ", "open.\n"; > print "openhandle( IN ) is ", openhandle( IN ) ? "" : "not ", "open.\n"; > print while <IN>; > open OUT, ">", \my $out or die $!; > print "fileno( OUT ) is ", fileno( OUT ) ? "" : "not ", "open.\n"; > print "openhandle( OUT ) is ", openhandle( OUT ) ? "" : "not ", "open.\n"; > print OUT "one two three four\n"; > print $out; > '
Oops, openhandle() requires a typeglob so that should be openhandle( *IN ) and openhandle( *OUT ). And Merry Christmas to all. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>