Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Practical example of "Is Perl code maintainable"

by DrHyde (Prior)
on Aug 16, 2007 at 11:11 UTC ( [id://633001]=note: print w/replies, xml ) Need Help??


in reply to Practical example of "Is Perl code maintainable"

sub file_mode { my $filename = shift; return -1 unless(-f $filename); return(stat($filename))[2]; }
The only significant change from your version being avoidance of magical _ in stat and the consequent reading of the parameter into a variable.

I might combine the two returns into one:

return (-f $filename) ? (stat($filename))[2] : -1

As far as I'm concerned, I'm not writing for an audience of novices. I'm writing for an audience of people employed to work on perl code, and I assume that my employer will provide training if he employed non-perl programmers. In the case of my own code, I'm writing for people who are sufficiently motivated to hack on it, who would usually be at least adequate perl hackers already. A novice with motivation can be expected to find a relevant book, or ask a question here or on his local perl mongers mailing list, or even ask me for help, and quickly stop being a novice.

Actually, in my own code I'm normally writing for an audience of me, and I am a hacker of very little brane who can never understand the neat tricks that he wrote the night before, and so tries not to do that.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-23 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found