nmerriweather has asked for the wisdom of the Perl Monks concerning the following question:
"my" variable $id masks earlier declaration in same scope
a quick fix was to replace it with this:if ( my $id = $obj->get_id() ) { $obj->do_this(); } elsif ( my $id = $obj->create_id() ) { $obj->do_that(); } else { $obj->do_somethingelse(); }
however, i'm wonderng if there's another way.my $id ; if ( $id = $obj->get_id() ) { $obj->do_this(); } elsif ( $id = $obj->create_id() ) { $obj->do_that(); } else { $obj->do_somethingelse(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: scoping question
by ikegami (Patriarch) on Mar 02, 2006 at 16:39 UTC | |
|
Re: scoping question
by vladb (Vicar) on Mar 02, 2006 at 16:38 UTC | |
by ikegami (Patriarch) on Mar 02, 2006 at 16:47 UTC | |
|
Re: scoping question
by Anonymous Monk on Mar 02, 2006 at 22:29 UTC | |
|
Re: scoping question
by nmerriweather (Friar) on Mar 03, 2006 at 03:14 UTC |