in reply to Private variable in class method does not go out of scope

Using a my declaration inside a postfix if is generally a bad idea.

Instead of

my $self = shift; my $data = shift if (@_);

please try changing your code to

Edit

From perlsyn

> NOTE: The behaviour of a my, state, or our modified with a statement modifier conditional or loop construct (for example, my $x if ... ) is undefined. The value of the my variable may be undef, any previously assigned value, or possibly anything else. Don't rely on it. Future versions of perl might do something different from the version of perl you try it out on. Here be dragons

Update

For further insights, see:

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

  • Comment on Re: Private variable in class method does not go out of scope ( 'my $x if...' / updated)
  • Select or Download Code