Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: my $x or my ($x)

by nmerriweather (Friar)
on Apr 05, 2006 at 19:11 UTC ( #541492=note: print w/ replies, xml ) Need Help??


in reply to my $x or my ($x)

if you're declaring 1 variable, its convoluted and a mess to do

my ($x) my $x; my $y; my $z;
but if you're instantiating a bunch of items before an eval block / loop:
my ( $x , $y , $z ); my ( $x , $y , $z );
both look cleaner to read and have a slighty faster perfomance (though its really insignficant). you can bench to see.

also: if you're doing oop perl:
sub function{ my $self = @_; }
is bad form - what if an argument is missing/extra?
sub function{ my ($self) = @_; }
is better. because you might want
sub function{ my ($self , $arg1 , $arg2 ) = @_; }


Comment on Re: my $x or my ($x)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2015-07-05 20:18 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 (68 votes), past polls