Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Please explain 'list' assignment.

by Errto (Vicar)
on Nov 03, 2006 at 19:11 UTC ( [id://582142]=note: print w/replies, xml ) Need Help??


in reply to Please explain 'list' assignment.

The way to do what you're looking for is
my $var1 = my $var2 = my $var3 = "Hello";
The reason your first piece of code doesn't do that is because it's a list assignment. That is, it takes a list of variables on the left side and a list of values on the right side. But the list on the left side has three items and the list on the right only has one, so the other two variables will get a value of undef.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-20 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found