in reply to Class array, push a new element
For what you've written, the line my @taskArray = @{ $self->{_tasks} }; assigns the content of the array referenced in $self->{_tasks} to a new array @taskArray, and this new array is the one that gets the new elements.sub addTask { my( $self, $task ) = @_; push @{$self->{_tasks}}, $task; return $task; }
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Class array, push a new element
by Anonymous Monk on Sep 07, 2014 at 22:53 UTC | |
by kennethk (Abbot) on Sep 07, 2014 at 23:07 UTC | |
by hatz (Initiate) on Sep 08, 2014 at 20:59 UTC |