The proper way to open()
sthoenna at gmail.com
Mon Jan 30 23:52:10 GMT 2012
On Mon, Jan 30, 2012 at 9:12 AM, David Cantrell <david at cantrell.org.uk> wrote:
> On Mon, Jan 30, 2012 at 05:03:47PM +0000, James Laver wrote:
>> On 30 Jan 2012, at 16:56, Dominic Thoreau wrote:
>> > open IN, '<', $cfg || handle_that_error_sub;
>> No, explicitly not. The || operator is far too high precedence binding. Use 'or' to remove your bug.
> No. The correct solution to buggy code caused by precedence is not to
> invent a new level of precedence, but to use parens. I do realise that
> it was the p5p gang who invented the new level of precedence, but that
> doesn't mean you should play along.
No. Use or for flow control and you won't find yourself fighting
against Perl. Reserve use of || for non-flow control. (For the
pedants, I define flow control as the operation being in void context
or an argument to a flow control and/or operation.)
Or always use parens with builtins. Some people advocate that anyway,
but I don't care for it.
And Larry, not p5p, AFAIK.
More information about the london.pm