[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;
'
fileno( IN ) is open.
openhandle( IN ) is not open.
one
two
three
four
fileno( OUT ) is open.
openhandle( OUT ) is not open.
one two three four


You can play along at home if you wish as this may not work the same with your
version of Perl.


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>


Reply via email to