Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Perl: last evaluated value as a returned value for a subroutine. See inside

by choroba (Chancellor)
on Feb 21, 2013 at 17:05 UTC ( #1019985=note: print w/replies, xml ) Need Help??


in reply to Perl: last evaluated value as a returned value for a subroutine. See inside

If you do not want the last value, return something else:
sub mySub { if ($R) { return; } else { print "CONDITION WORKS\n"; $R = "some string\n"; } }

Usually, your subroutine should return a value and not print anything, or it should print something, but then you should call it in a void context (or a boolean one, checking for success). Making it both print and return a value to be printed makes it harder for reuse.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: Perl: last evaluated value as a returned value for a subroutine. See inside
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019985]
help
Chatterbox?
[Tux]: in the dialog area it shows correct, but the url is broken in the CB
[Discipulus]: you still need to put href:// , no?
[Tux]: [htps://metacpan. org/source/ MLEHMANN/Canary- Stability-2012/ Stability.pm#L124| this] is the same link posted on the PM side inside the CB
[Discipulus]: and you wrote ttps and then htps
[Tux]: new try
[Tux]: \o/ (sorry for the noise)
[Discipulus]: anyway, i'm more interested about the general idea: you (and others) do not install modules by this guy. Rigth?
[Tux]: correct
[Tux]: and I know about companies that blocked him for legal reasons. His inability to fix issues (or his tendency to reject/delete issues if he doesn't like them) makes companies block his stuff. They require support
[Discipulus]: ok, and I can imagine is a rationale behaviours. So MCE::Hobo is using one of such modules and automatically become 'blacklisted' for some perl dev

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2017-09-20 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (234 votes). Check out past polls.

    Notices?