Re: More idiomatic

Discussion in 'Perl Misc' started by Peter Makholm, Apr 16, 2013.

  1. Ben Morrow <> writes:

    > With a constant filename, it's not so important, but it's safer to get
    > into the habit of using 3-arg open:
    >
    > open my $fin, "<", "t1.txt";


    ....

    > It's usual (though not universal) to use variable names in all caps for
    > filehandles.


    Is it?

    For lexical filehandles I would usually use lower case and only use all
    caps for the global non-lexical filehandelse. That is either

    open(my $fh, "<", "somefile.txt") or die

    or

    open(FH, "<", "somefile.txt") or die

    Though I would only very rarely use the latter. This usage follows the
    conventions in the 'perldof -f open' documentation and is also the style
    I mostly find on CPAN.

    //Makholm
     
    Peter Makholm, Apr 16, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zed A. Shaw
    Replies:
    2
    Views:
    108
    Zed A. Shaw
    Apr 23, 2005
  2. Charles Calvert
    Replies:
    33
    Views:
    363
    w_a_x_man
    Oct 22, 2010
  3. Alan Mead
    Replies:
    4
    Views:
    142
    Alan Mead
    Feb 12, 2005
  4. J. Gleixner

    Re: More idiomatic

    J. Gleixner, Apr 15, 2013, in forum: Perl Misc
    Replies:
    11
    Views:
    276
    Rainer Weikusat
    Apr 16, 2013
  5. Rainer Weikusat

    Re: More idiomatic

    Rainer Weikusat, Apr 15, 2013, in forum: Perl Misc
    Replies:
    1
    Views:
    164
    Rainer Weikusat
    Apr 15, 2013
Loading...

Share This Page