What is Perl doing with this argument to push in this case?

Posted by Morinar on Stack Overflow See other posts from Stack Overflow or by Morinar
Published on 2010-03-30T19:11:56Z Indexed on 2010/03/30 19:13 UTC
Read the original article Hit count: 234

Filed under:

I just saw some code in our code base (and it's OLD code, as in Perl 3 or Perl 4 days) that looks like this (I'm simplifying greatly):

 my @array;
 push( array, $some_scalar );

Notice that the array in the push() doesn't have an @. I would assume that the code behind push knows that the first argument is supposed to be array so grabs the array from the array typeglob. Is that more or less it? If Perl is able to do that without problem, why would you need to include the @ at all?

© Stack Overflow or respective owner

Related posts about perl