At 02:34 -0500 13/01/2011, shawn wilson wrote:
I dig what you're saying about always using return. However I don't (have
never used / seen) a case where a sub returns last expression. An example
maybe?
#!/usr/local/bin/perl
use strict;
use feature qw(say);
say &SUB();
sub SUB {
my $word = "
On 2011-01-13 08:18, John W. Krahn wrote:
If you want to return a false value it is usually better to use return
with no value:
return;
I prefer subs to normally return a single scalar, which can be a direct
value like undef, or a reference to a more complex data structure, etc.
If you all
On 2011-01-12 22:23, Parag Kalra wrote:
On shell, successful command returns exit status of 0.
As a best practice what status value shall a Perl function return.
A function can return other kinds of values too.
Going by the fact that Perl function returns the value of last command
in it, I
> "sw" == shawn wilson writes:
sw> I dig what you're saying about always using return. However I
sw> don't (have never used / seen) a case where a sub returns last
sw> expression. An example maybe?
the classic case which is used in the constant pragma is:
sub FOO() { 'foo' }
On Jan 13, 2011 2:24 AM, "Uri Guttman" wrote:
>
> > "sw" == shawn wilson writes:
>
> >> subs in perl ALWAYS return something, either the value from return or
> >> the last evaluated expression.
>
> sw> What do you mean by this?
>
> sw> sub nothing {
> sw> my $something = 5;
> sw> if ( $
> "sw" == shawn wilson writes:
>> subs in perl ALWAYS return something, either the value from return or
>> the last evaluated expression.
sw> What do you mean by this?
sw> sub nothing {
sw> my $something = 5;
sw> if ( $something == 5) {}
sw> }
sw> ... will return 'undef' an
Octavian Rasnita wrote:
From: "Parag Kalra"
On shell, successful command returns exit status of 0.
As a best practice what status value shall a Perl function return.
Going by the fact that Perl function returns the value of last command
in it, I think function should return non-zero for a su
> subs in perl ALWAYS return something, either the value from return or
> the last evaluated expression.
What do you mean by this?
sub nothing {
my $something = 5;
if ( $something == 5) {}
}
... will return 'undef' and not 5 or anything else, right?
> "OR" == Octavian Rasnita writes:
OR> Perl doesn't use functions, but subroutines or methods, so they don't
don't say that. subs and functions are just synonyms. it is how you use
the sub that changes its meaning.
OR> need to return something if you don't want them to return something.
From: "Parag Kalra"
Hi,
On shell, successful command returns exit status of 0.
As a best practice what status value shall a Perl function return.
Going by the fact that Perl function returns the value of last command
in it, I think function should return non-zero for a success.
Cheers,
Parag
> "PK" == Parag Kalra writes:
PK> Hi,
PK> On shell, successful command returns exit status of 0.
PK> As a best practice what status value shall a Perl function return.
a shell command is NOT a function call. comparing them is useless.
PK> Going by the fact that Perl function return
Hi,
On shell, successful command returns exit status of 0.
As a best practice what status value shall a Perl function return.
Going by the fact that Perl function returns the value of last command
in it, I think function should return non-zero for a success.
Cheers,
Parag
--
To unsubscribe, e
12 matches
Mail list logo