With salt firmly on tongue,

For something that's not so obvious such as the fact that the map is being returned, it would seem better style to explicitly return it for clarity. The long route is to save the contents in an array and return the array. The short route is to tack a return statment on the fron of the map. Demonstrate:

my @map = map {chomp; qr/$_/} <FH>; return @map; # or return map {chomp; qr/$_/} <FH>;
Which is clearer? You be the judge, you'll have to maintain it, but i generally go for no unnecessary temporary variables.

Secondly, the bare _ in the filetest seems just fine since it's coupled with the other file test immediately. If you were doing filetests on the same filename but seperated (even if only be whitespace) it might be clearer to explicitly put in the filename (in this case $file). On the other hand, as said before, you're the one maintaining this, so if it's not clear to you, then it definitely won't be clear to the next guy (as a rule of thumb).

jynx


In reply to Re: Scope and Context by jynx
in thread Scope and Context by rob_au

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.