Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: my $x or my ($x)

by strat (Canon)
on Apr 05, 2006 at 08:08 UTC ( #541302=note: print w/replies, xml ) Need Help??


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

If you just write my $x; or my ($x); there is no important difference

but if you assign values to the variable and have functions or the like that behave differently in scalar or list context, there may be problems, e.g.

open (my $FH, "<", $file) or die ... # reads the whole file, assigns first line to $headline my ($headline) = <$FH>; # since the whole file is already read, there's nothing # more to be read, so the while block will never be executed while( my $line = <$FH> ) {

or:

sub xxx { # error, must be my ($firstParam) = @_; if you don't want # to get the number of parameters but the first param my $firstParam = @_; ...

or:

my $x = reverse('abcdef'); my ($y) = reverse('abcdef'); print "x=$x\ny=$y\n";

or localtime, caller, regular expressions,...

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://541302]
help
Chatterbox?
[Corion]: But a quick Google search turns up this page, which seems to suggest that it should be packaged
[Discipulus]: iirc active perl has repositories only for last 2 o 3 major release of perl Mj1234. I strongly suggest portable version of strawberry perl and use cpan client to install modules
[choroba]: Also, who needs GDB when there's hdb?
[Discipulus]: in this ubuntu i'm not able to find resource monitor, graphical mount program.. just office and amazon are exposed!

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2016-12-07 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (125 votes). Check out past polls.