develooper Front page | perl.perl5.porters | Postings from August 2009

Re: [DOC] Modernization: perldata

Thread Previous | Thread Next
From:
Flavio Poletti
Date:
August 30, 2009 04:05
Subject:
Re: [DOC] Modernization: perldata
Message ID:
aeba50980908300404t31cf5813hce1b2f26d791e5af@mail.gmail.com
On Sun, Aug 30, 2009 at 12:03 PM, Ben Morrow <ben@morrow.me.uk> wrote:

> Quoth polettix@gmail.com (Flavio Poletti):
> >
> > -    $who = "Larry";
> > -    print PASSWD "${who}::0:0:Superuser:/:/bin/perl\n";
> > +    my $who = "Larry";
> > +    print $passwd_fh "${who}::0:0:Superuser:/:/bin/perl\n";
>
> (I'm being picky again, and I don't like it. Please tell me to stop when
> it gets annoying.)


I think that being picky might help in general, it could unveil things that
the corrector didn't think of.


I usually stick to the convention of using uppercase for filehandles,
> even when they're in variables. It just helps visually distinguish them.
> I'd write this
>
>    print $PASSWD "...";
>

Sloppily applying your logic for the other correction (the one about the
quotes in hashes keys) I'd say that I never saw anything like this in the
docs: everywhere they use lexical variables for filehandles, they are
lowercase. Sloppily here means that I won't likely verify my statement on
the whole documentation base :-)

On the other hand, I agree with H.Merjin Brand about using a simple $fh
here; anything else would distract attention from the real topic, i.e. using
braces to access variables' contents. I also think that using lexical
filehandles generally allows you to "anonymize" the corresponding variable
name to a simple $fh, due to the (generally) restricted scope, so I'd
probably use $fh even in production code.

Cheers,

   Flavio.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About