On Fri, Aug 10, 2001 at 10:42:32AM +0500, Rizwan Majeed wrote:
> It is known that passing a list by value to a function does not make
> visible to the calling function changes made to the list.

That isn't necessarily true.  The code:

    sub my_push (\@@) { push(@{ $_[0] }, @_[1 .. $#_]) }

    @foo = qw(foo bar);
    my_push(@foo, qw(baz qux));

    print "@foo\n";

Will output:

    foo bar baz qux

See perldoc perlsub, look for documentation on prototypes.


> But I dont understand how does the push() function works. Push takes the
> value of a list and still makes visible to the calling block of code the
> changes to the list.
> 
> Can anyone please explain.

push is a builtin operator, and builtin operators can do pretty much
whatever they need to do to get their jobs done.  If you want further
explanation on how exactly push goes about it, RTSL.  :)


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--


P.S. That's "Read the Source, Luke".

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to