in reply to Re: Class array, push a new element
in thread Class array, push a new element

I think you've got a bug there; are you sure that the object contains the tasks after your push?

I think the line @{ $self->{_tasks} } = @taskArray; takes care of that?

Anyway, your version is indeed the shorter & more efficient one.

hatz, you may want to look at perlreftut and perlref.

Replies are listed 'Best First'.
Re^3: Class array, push a new element
by kennethk (Abbot) on Sep 07, 2014 at 23:07 UTC
    My eyes are broken. I should definitely not be working on a Sunday....

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Thank you for your answers!

      Indeed the syntax you wrote looks better :

      push @{$self->{_tasks}}, $task;

      It does not raise the warning anymore ("push on reference is experimental at Project.pm line 40").

      I will get more familiar with references and how to get an array, hash or string out of one.

      Thank you again!