Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Please explain 'list' assignment.

by Errto (Vicar)
on Nov 03, 2006 at 19:11 UTC ( #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
Node Status?
node history
Node Type: note [id://582142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2021-04-23 17:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?