in reply to Re: Is this bad coding style?
in thread Is this bad coding style?
writing $_ == 1 is dangerous because it is too easy to drop an = and assign rather than compare.
Some like to put constants on the LHS (1 == $_) to avoid that problem.
>perl -e"$_ = 0; die qq{uh oh!\n} if $_ = 1;" uh oh! >perl -e"$_ = 0; die qq{uh oh!\n} if 1 = $_;" Can't modify constant item in scalar assignment at -e line 1, near "$_ +;" Execution of -e aborted due to compilation errors.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is this bad coding style?
by tilly (Archbishop) on Jan 08, 2009 at 06:15 UTC |