in reply to Please explain 'list' assignment.
Because list assignments are parallel. A list of three items on the left expects three items on the right. Since there's only one, $var2 and $var3 remain undefined.
You can do what you want with:
Update: Oops - I read your question slightly wrong. To assign the same value three times, use
ormy ($var1, $var2, $var3) = map "Hello", 1..3;
(thanks Sidhekin)my ($var1, $var2, $var3) = ("Hello") x 3;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Please explain 'list' assignment.
by shenme (Priest) on Nov 03, 2006 at 19:19 UTC | |
|
Re^2: Please explain 'list' assignment.
by Bagarre (Sexton) on Nov 03, 2006 at 19:20 UTC | |
|
Re^2: Please explain 'list' assignment.
by Bagarre (Sexton) on Nov 03, 2006 at 19:12 UTC |