Doctrin has asked for the wisdom of the Perl Monks concerning the following question:
Hello dear Monks again!
I have some code:
So, Perl returns last evaluated value. My question is: are there any conditions when Perl would NOT print "some string" in last two lines of code? Thanks!use strict; my $R; sub mySub { unless ($R) { print "CONDITION WORKS\n"; $R = 'some string'; } } print mySub(); #prints CONDITION WORKS\nsome string print mySub(); #prints some string print mySub(); #again
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl: last evaluated value as a returned value for a subroutine. See inside
by moritz (Cardinal) on Feb 21, 2013 at 17:18 UTC | |
Re: Perl: last evaluated value as a returned value for a subroutine. See inside
by choroba (Cardinal) on Feb 21, 2013 at 17:05 UTC | |
Re: Perl: last evaluated value as a returned value for a subroutine. See inside
by swkronenfeld (Hermit) on Feb 21, 2013 at 17:02 UTC | |
by sundialsvc4 (Abbot) on Feb 21, 2013 at 17:38 UTC | |
by Anonymous Monk on Feb 22, 2013 at 00:38 UTC | |
Re: Perl: last evaluated value as a returned value for a subroutine. See inside
by blue_cowdawg (Monsignor) on Feb 21, 2013 at 17:15 UTC | |
Re: Perl: last evaluated value as a returned value for a subroutine. See inside
by LanX (Saint) on Feb 21, 2013 at 17:00 UTC |
Back to
Seekers of Perl Wisdom