B
Bernard Chan
Hello,
I have finally been able to get an output buffering module I mentioned
in an earlier post to work. Though the module is complete and works as
expected, I'm still not sure how some of the code I wrote actually works.
I tried this: ====================
perl -Mstrict -e 'local *FH = "STDOUT"; print FH "Test Message\n"'
It seems like FH now points to the filehandle STDOUT with the
assignment. I forgot if anywhere in the perldoc mentioned this
behaviour, or I just got it "discovered" by accident. And also, isn't
this regarded as a symbolic reference, but Perl under strict 'refs'
doesn't complain?
Another mystery: ================
my $BUF;
open my $FH, ">", \$BUF;
print ref($FH)
outputs "GLOB".
From the perldocs my perception is that typeglobs are symbol table
entries. But now $FH is a lexical, so it is not on the symbol table.
Then where does the GLOB come from? What does it contain?
Now, $FH being a lexical, *$FH{GLOB} exists, but what is contained in
it? And *{$FH{GLOB}}{GLOB}, ... ?
Hope some brilliant minds here may give me some insights.
Regards,
Bernard Chan.
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
I have finally been able to get an output buffering module I mentioned
in an earlier post to work. Though the module is complete and works as
expected, I'm still not sure how some of the code I wrote actually works.
I tried this: ====================
perl -Mstrict -e 'local *FH = "STDOUT"; print FH "Test Message\n"'
It seems like FH now points to the filehandle STDOUT with the
assignment. I forgot if anywhere in the perldoc mentioned this
behaviour, or I just got it "discovered" by accident. And also, isn't
this regarded as a symbolic reference, but Perl under strict 'refs'
doesn't complain?
Another mystery: ================
my $BUF;
open my $FH, ">", \$BUF;
print ref($FH)
outputs "GLOB".
From the perldocs my perception is that typeglobs are symbol table
entries. But now $FH is a lexical, so it is not on the symbol table.
Then where does the GLOB come from? What does it contain?
Now, $FH being a lexical, *$FH{GLOB} exists, but what is contained in
it? And *{$FH{GLOB}}{GLOB}, ... ?
Hope some brilliant minds here may give me some insights.
Regards,
Bernard Chan.
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***