Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Possible precedence issue with control flow operator

by LanX (Cardinal)
on Jan 13, 2020 at 18:48 UTC ( #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
Node Status?
node history
Node Type: note [id://11111371]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2020-09-29 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (146 votes). Check out past polls.

    Notices?