You can also mix the variables on the right side and if there are arrays on the right side the whole thing becomes one flat array !
my $owner = "Moose"; my @tenants = qw(Foo Bar); my @people = ($owner, 'Baz', @tenants); # Moose Baz Foo Bar my ($x, @y, @z); ($x, @y) = (1, 2, 3, 4); # $x is 1; @y is (2, 3, 4) ($x, @y, @z) = (1, 2, 3, 4); # $x is 1; @y is (2, 3, 4) @z is empty: () @y = (); # Emptying an array
| Prev | Home (Copyright Gabor Szabo) Perl Training Israel | Next |
| Create an Array, loop over with foreach | Up | foreach loop on numbers |