in reply to Checking for "return undef"
return controls what the sub returns, but you aren't using a return value. load_session isn't ever going to change $s. Try:sub load_session { ... return undef; ... } And now consider my code: ... $sid = $cookies->{license_session}->value(); # load session from db my $s = Mapps::Session->new(); $s->load_session($sid); # session is good continue if (defined $s){ $m->call_next; }
(Actually, a method can change the object it is called on, by assigning to $_[0]. This came as a surprise to me.)if (defined $s->load_session($sid)) { $m->call_next; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Checking for "return undef"
by Ovid (Cardinal) on Apr 21, 2004 at 16:33 UTC | |
by ysth (Canon) on Apr 21, 2004 at 18:35 UTC | |
by tye (Sage) on Apr 21, 2004 at 19:29 UTC |