On Wed, Jul 27, 2011 at 9:30 AM, Rob Dixon <rob.di...@gmx.com> wrote:
> What exactly is wrong with "or do {...}"?
>
> I believe it is the best option simply because is is comparable to the
> common "open ... or die $!" idiom. The do is there only so that a
> warning can be issued as well as the return

There's nothing wrong with issuing an "or do {...}" especially if you
want to do multiple things on failure.

open(my $fh, '<', $somefile) or do {
    log_the_error("Could not open $somefile - $!");
    do_something_else();
    return;
};

Kevin.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to