On Sat, Jul 30, 2005 at 02:33:15PM +0200, Ingo Blechschmidt wrote:
: my @array = <a b c>;
: my $arrayref := @array;
: push $arrayref, "c";
: say [EMAIL PROTECTED]; # a b c d, no problem
: $arrayref = [<d e f>];
: say [EMAIL PROTECTED]; # d e f, still no problem
: $arrayref = 42; # !!! 42 is not a Ref of Array
: Should the last line be treated as
: $arrayref = (42,);
: which, as the LHS is in scalar context, would auto-referize to
: $arrayref = ;
: which would work?
: Or should that be an error?
: (FWIW, I favour option 2.)
Why shouldn't it do option 3, which is to work like in Perl 5?
It should only be an error if $arrayref is declared with a type
inconsistent with 42. Assignment goes to the container, not the
current contents of that container.