Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Practical example of "Is Perl code maintainable"

by DrHyde (Prior)
on Aug 16, 2007 at 11:11 UTC ( #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.


Comment on Re: Practical example of "Is Perl code maintainable"
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-08-21 17:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (139 votes), past polls