On 11-03-30 12:58 PM, siegfr...@heintze.com wrote:
Can you explain to me why the camel book uses all caps for file handles that are
not preceded by a "@", "%", "$" or "*" and you use "$fh"? What are the rules for
declaring file handles? I thought file handles were wierdo's and had to be
declared with "local" and I see you used "my" to declare $fh.

I also see you are storing a reference to *STDIN in $fn. What is *STDIN? Is it a
glob? If you are storing a reference, why don't you have to add an extra level
of dereferencing and say

while (<$$fh>){ .... }

The camel book is out of date. Lexical-scoped variables (aka my variables) could be used since Perl 5.6, I think. They are recommended over our variables. In older Perl versions, you could only use bare words for file handles so the convention was to capitalize them so they would stand out.

*STDIN is a typeglob, so named to distinguish it from the glob() function. I'm not sure why the syntax works; it just does. Also, this works:

  $fh = *STDIN;


See:
`perldoc perldata` and search for /Typeglobs and Filehandles/
`perldoc -f open`
`perldoc perlopentut`


--
Just my 0.00000002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to