saranperl has asked for the wisdom of the Perl Monks concerning the following question:
The above code . i am writing push function. I passed @a as a reference and i add 5 at end of the array. i print @a in main program. because i am passing reference. Then In actual push statement(push(@a,5)),without using reference,how its work?@a=(1,2,3,4); push1(\@a,5); print @a; sub push1{ $ref =shift; @a = @$ref; $s=shift; $len=scalar @a; $a[$len] =$s; return \@a; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: technique of push
by ikegami (Patriarch) on Sep 02, 2009 at 07:07 UTC | |
by saranperl (Initiate) on Sep 02, 2009 at 07:14 UTC | |
by ikegami (Patriarch) on Sep 02, 2009 at 07:22 UTC | |
|
Re: technique of push
by Utilitarian (Vicar) on Sep 02, 2009 at 07:54 UTC |