[Israel.pm] scalars and arrays
Yaakov Belch
lists at yaakovnet.com
Sun Feb 15 04:37:59 PST 2004
>
>
>I know that: @array[$y]=8; should be written as: $array[$y]=8;
>But what is really happens when I write it as in the first example ?
>
@array[$i1,$i2,$i3,...] is an abbreviation for the list ($array[$i1],
$array[$i2],$array[$i3],...).
By the way, the @hash{$k2,$k2,$k3,...} is an abbreviaiont for the list
($hash{$k1},$hash{$k2},$hash{$k3}).
This feature is called "array slices" (or, respectively, "hash slices")
and is occasionally very useful.
Thus, @array[$y]=8 means ($array[$y])=(8); because the left hans side is
a list, the
right hand side is evaluated as a list (one element: 8). In the end,
you get the same result
as $array[$y]=8.
>Why @array isn't modified ?
>
>
I tested that on my perl and @array[$y]=8 really changes the list @array.
Yaakov
More information about the Perl
mailing list