Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Possible precedence issue with control flow operator

by LanX (Saint)
on Jan 13, 2020 at 18:48 UTC ( [id://11111371]=note: print w/replies, xml ) Need Help??


in reply to Re: Possible precedence issue with control flow operator
in thread Possible precedence issue with control flow operator

A return is evaluated in the context of the sub's caller.

so this variant

my $result; $result = something() or croak "Something went wrong"; return $result;

is safer (resp. only correct) if it's supposed to be a scalar.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11111371]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found