[Perl] constant pragma question

Shlomi Fish shlomif at vipe.stud.technion.ac.il
Tue Oct 22 09:49:36 PDT 2002


On Tue, 22 Oct 2002, Shlomo Yona wrote:

>
> Hello,
>
> Check this out:
>
> perl -Mstrict -we 'use constant ARRAY => [ 1,2,3,4 ]; print ARRAY->[1]; ARRAY->[1] = " be changed"; print ARRAY->[1],"\n";'
>
> prints out;
>
> 2 be changed
>
> and this is totally not what I expected.
>
> I expected to see:
>
> " be changed"
>
> Can someone explain? Where did the concatenation take place and why?
>

you've printed it once right after the constant declaration:

print ARRAY->[1];

this would print 2.

Regards,

	Shlomi Fish


>



----------------------------------------------------------------------
Shlomi Fish        shlomif at vipe.technion.ac.il
Home Page:         http://t2.technion.ac.il/~shlomif/

He who re-invents the wheel, understands much better how a wheel works.




More information about the Perl mailing list