Re: i don't understand 'context sensitivity'



On 2011-01-14, Anster wrote:

what is different between

@array = ('a', 'b', 'c');

and

($array[0], $array[1], $array[2]) = ('a', 'b', 'c');

?

# Begin example 1
my @array = ('q', 'w', 'e', 'r');

print "Before:\n";
print "$_\n" for @array;
print "After:\n";
@array = ('a', 'b', 'c');
print "$_\n" for @array;

# End example 1

Before:
q
w
e
r
After:
a
b
c

# Begin example 2
my @array = ('q', 'w', 'e', 'r');

print "Before:\n";
print "$_\n" for @array;
print "After:\n";
($array[0], $array[1], $array[2]) = ('a', 'b', 'c');
print "$_\n" for @array;

# End example 2

Before:
q
w
e
r
After:
a
b
c
r


To see the difference between two things, just experiment! ;-)

--
Vivien MOREAU

.