in reply to Re: Elegant way to return true or nothing from a subroutine?
in thread Elegant way to return true or nothing from a subroutine?
undef isn't the same as "nothing":
#!/usr/bin/perl -w use strict; sub ret_undef { return undef } sub ret_nothing { return; } print ret_nothing(), "\n"; print ret_undef(), "\n"; my @foo = ret_nothing(); print "Elements in foo: ", scalar @foo, "\n"; print @foo; my @bar = ret_undef(); print "Elements in bar: ", scalar @bar, "\n"; print @bar;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Elegant way to return true or nothing from a subroutine?
by GrandFather (Saint) on Oct 10, 2006 at 02:14 UTC | |
by chromatic (Archbishop) on Oct 10, 2006 at 04:33 UTC | |
by fenLisesi (Priest) on Oct 10, 2006 at 12:20 UTC |