This is wrong:
return something() or die "something went wrong";
This is right:
return something || die "something went wrong";
(source)
The former will generate a warning:
Possible precedence issue with control flow operator
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
Showing posts with label die. Show all posts
Showing posts with label die. Show all posts
When to use "or" and when to use || (double pipe) in Perl
Rollback within a txn_do for DBIC
try {
$self->schema->txn_do(sub {
# something went bad
die 'argh';
});
}
catch ($e) {
# log me
# no roll back needed
}
Subscribe to:
Posts (Atom)