in reply to Amazing syntax of push (was Re: Removing duplicates in Array of Array)
in thread Removing duplicates in Array of Array

Seems you do not need either push or anonymous arrays to see the behaviour with 5.8.6:

c:\test>perl -Mstrict -MData::Dump=pp -wle"my @r=1..10; @{ @r }='a'..'c'; pp \@r" ["a", "b", "c"]

@{ @r } seems to function exactly the same as either @r alone (or @{ \@r }). Which is somewhat bizarre.

But not so with 5.10

c:\test>\perl510\bin\perl -MData::Dump=pp -wle"my @r=1..10; @{ @r }='a'..'c'; pp \@r" [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] c:\test>\perl510\bin\perl -Mstrict -MData::Dump=pp -wle"my @r=1..10; @{ @r }='a'..'c'; pp \@r" Can't use string ("10") as an ARRAY ref while "strict refs" in use at +-e line 1.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Amazing syntax of push (was Re: Removing duplicates in Array of Array)
by parv (Parson) on Sep 04, 2008 at 07:58 UTC
    I see that I missed a step: run the program with perl 5.10.0. So, the program parses|compiles ok but causes run time error as above (in my example 10 in above error message is a 2). For the record, perl 5.8.8 produces neither compile time nor run time error.