in reply to Re: why does push not default to $_?
in thread why does push not default to $_?
Well for me, calling push with only one parameter is quite obvious. At least not less than print without parameter.
Please, in which chapter did you find that quote in the camel book?
Cheers Rolf
Here are the places where Perl will assume $_ even if you don't use it:
* Various unary functions, including functions like ord and int,
as well as all the file tests (-f, -d) except for -t, which defaults to STDIN.
* Various list functions like print and unlink.
* The pattern-matching operations m//, s///, and tr/// when used
without an =~ operator.
* The default iterator variable in a foreach loop if no other variable
is supplied.
* The implicit iterator variable in the grep and map functions.
* The default place to put an input record when a <FH> operation's
result is tested by itself as the sole criterion of a while test. Note that
outside of a while test, this will not happen.
Mnemonic: underline is the underlying operand in certain operations.
Well various doesn't sound very specific, and print and unlink are not unary.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: why does push not default to $_?
by ptoulis (Scribe) on Dec 06, 2008 at 01:53 UTC | |
by LanX (Saint) on Dec 06, 2008 at 02:13 UTC |