Don't assign to
$_ without localizing it first!
$_ is usually aliased to another variable, and your code would clobber it. The fix is to add
local to the first assignment (as shown below). However, if you do that, you've gained nothing but obfuscation. You should use
my $id instead of
local $_.
if ( local $_ = $obj->get_id() ) # XXX Use "my $id =" instead of
{ # "local $_ =" for clarity.
$obj->do_this();
}
elsif ( $_ = $obj->create_id() ) # XXX Use "$id =" instead of
{ # "$_ =" for clarity.
$obj->do_that();
}
else
{
$obj->do_somethingelse();
}