At 09:22 AM 5/28/02 -0400, William West wrote:
>   b) you might want to pass in a reference to the array - and fill it up
>
>                         push( @$array_ref, $_ )
>....
>
>i almost understand this- not really though...

I'm not sure what it was for either, missed the earlier part of the thread 
- if you have an array reference for some other purpose, then sure, that's 
how to use the ref in a push call.

But it is worth mentioning that there's nothing being gained in using a ref 
in the *push* statement.  push() is internally prototyped to take a first 
argument which begins with an @ sign, followed by a list of things.  That 
means that the first argument is *converted to a reference* by Perl 
automatically.  (Well, since push() is implemented internally, it's not 
quite the same, but close enough.)  That's how come Perl knows what array 
to modify, instead of just seeing a flat list of everything in the array 
followed by everything to be pushed onto it (which would be useless).

Further enlightenment is available in the perlsub page under "Prototypes", 
in particular, how to Do This Yourself.
--
Peter Scott
Pacific Systems Design Technologies        Boston Perl Classes in July:
http://www.perldebugged.com/               http://stemsystems.com/class/


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

Reply via email to