Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: why does push not default to $_?

by ikegami (Patriarch)
on Dec 04, 2008 at 21:38 UTC ( [id://728109]=note: print w/replies, xml ) Need Help??


in reply to why does push not default to $_?

That would break

push @a, @b;

It would push $_ when @b is empty instead of push nothing as expected.

Update: Or maybe not. That's doesn't break print, after all.

Replies are listed 'Best First'.
Re^2: why does push not default to $_?
by LanX (Saint) on Dec 04, 2008 at 21:47 UTC
    Good argument, but whats the difference to
    print @b;
    if @b is empty? It doesn't print $_
    for (1..13) { print @b; }
    Furthermore there is no error with:
    push @a, @b;
    but you get a warning with
    push @a;
    so perl can distinguish between missing parameters and empty parameters...

    Cheers Rolf

      Yeah, I already noticed and updated my node.

      The only possible reason I could see if an undue burden on the parser, since it would be the first function to default the second argument. You could send a perl (wishlist) bug report?

        hmm, I thought it may be a compiler limitation on the first argument, but split defaults to $_ on its second argument, (' ' on first one)

        I think there is no logical reason!

        Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://728109]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-18 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found