Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Declaring my $var versus declaring my($var)

by biohisham (Priest)
on Jun 10, 2011 at 14:16 UTC ( #909130=note: print w/ replies, xml ) Need Help??


in reply to Declaring my $var versus declaring my($var)

is there any practical difference between using parenthesis for a single variable declaration (my($var);) and omitting them (my $var;)?
I can't test if there's any benchmark performance difference or if Perl::Critic has something to say about either styles, parenthesis impose list context in this scenario, and a list can be made of one or more elements.

This Post is in line and discusses a similar matter. The assignment to a scalar variable of a return value from a function (i.e such as stat()) or from an array gives the variable a value depending on the context in which the variable has been assigned, quoting an example below:

my ($var) = @array ; my $var = @array;



Excellence is an Endeavor of Persistence. A Year-Old Monk :D .


Comment on Re: Declaring my $var versus declaring my($var)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2015-07-05 07:21 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 (60 votes), past polls