in reply to Re: unshifting by reference
in thread unshifting by reference

Thx it works (obvious it was ^^).
But I don't et it, I thought that the "->" dereferences, doesn't it ?
when I did print $this->{N}[0]{Value}; it worked ok, so whats the difference ?
Why didn't I needed to dereference there ?
and whats "Dumper" is this really required ? (I prefer to avoid module dependencies)
Thx again

Replies are listed 'Best First'.
Re^3: unshifting by reference
by Eliya (Vicar) on Dec 16, 2011 at 00:51 UTC

    The thing is that unshift needs an array (syntactically), not an array reference. And the way to get an (entire) array from a reference is to say @$aref, or @{ $something->{that}{returns}[1]{aref} } for more complex expressions.  To address a single element of the array, you'd say $aref->[$index].

    (The Data::Dumper module is to easily print out complex data structures. I just used it for demo purposes — you of course don't need it to unshift the value.)

Re^3: unshifting by reference
by ikegami (Patriarch) on Dec 16, 2011 at 01:36 UTC

    -> is dereferencing a hash that has nothing to do with your question.

    Your question is about dereferencing the array referenced by $this->{N}.

Re^3: unshifting by reference
by ikegami (Patriarch) on Dec 16, 2011 at 01:37 UTC

    -> is dereferencing a hash that has nothing to do with your question.

    Your question is about dereferencing the array referenced by $this->{N}.