in reply to Re: and multiple statements
in thread and multiple statements

But an if would be clearer.
Is it? Always? For everyone?

Considering the idom open ... or die ... is quite common, I'd say that

open ... or do {...;...}
is clearer than
if (!open ...) { ...; ... }
I'd certainly write the former.

Replies are listed 'Best First'.
Re^3: and multiple statements
by ikegami (Patriarch) on Jun 06, 2010 at 19:22 UTC
    It's quite common because it's required in the case of open(my $fh, ...), not because it's clearer.
      Required? I don't follow.
      if (!open my $fh, "<", "filename") { warn "Whatever"; return; }
      is perfectly valid code. There's no requirement that that is to be written as
      open my $fh, "<", "filename" or do {warn "Whatever"; return;};
        Perfectly valid code, but perfectly useless because you can't use the file handle you just opened. You'd have to move the rest of the code into the else body.