Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Some suggestions on coding style - a chance to critique

by Aristotle (Chancellor)
on Jun 26, 2002 at 15:51 UTC ( #177412=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Some suggestions on coding style - a chance to critique
in thread Some suggestions on coding style - a chance to critique

Dump the "&" in front of subroutine calls.
  1. Using & disables a function's prototype.
  2. If you don't pass any parameters to a function, but call it using &, it will receive your current @_ as its parameters. This can lead to very hard to spot errors.
Is it just that I should use the hash in my code as opposed to assigning the hash values to a variable and then using the variable instead?
Indeed. Why assign to a hash first when you're going to put it into a variable afterwards? Using a hash also is usually cleaner, since it provides an own little name space for the variables in question; it keeps together what belongs together, and keeps them from littering the global namespace.
What exactly does the $|=1 do?
It disables buffering for the currently selected filehandle (which would usually be STDOUT). See perlvar.

Makeshifts last the longest.


Comment on Re^3: Some suggestions on coding style - a chance to critique
Replies are listed 'Best First'.
Re: Re^3: Some suggestions on coding style - a chance to critique
by myocom (Deacon) on Jul 01, 2002 at 19:02 UTC
    For a more elaborate discussion of & vs. non-& sub calls, check the replies that followed from one of my early posts, A question of style. Notably, tye's excellent post here.
    "One word of warning: if you meet a bunch of Perl programmers on the bus or something, don't look them in the eye. They've been known to try to convert the young into Perl monks." - Frank Willison

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2015-07-30 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls