in reply to Scoping question
While you can't use $item before the end of the statement, you can use the return value from the my (which is, not surprisingly, the same value). If the value is false, you push an empty list, which doesn't change the array.push @{$self->{'select'}}, (my $item = $self->grid($x, $y) or ());
And if you don't need $item elsewhere, you can just leave the assignment out:
push @{$self->{'select'}}, ($self->grid($x, $y) or ());
|
|---|