Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Scope and Context

by jynx (Priest)
on Nov 14, 2001 at 06:29 UTC ( [id://125211]=note: print w/replies, xml ) Need Help??


in reply to Scope and Context


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://125211]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found