f



no "won't stay shared" warning for "use constant" anon subs

Seems like we're missing the "will not stay shared" warning for anon
subs declared via "use constant". Is this a bug? Please cc: me on
replies.

use strict;
use warnings;
sub foo{
  my($c,$d,$e)=("x","y","z");
  my $bob=sub{$c=$_[0] if @_};
  use constant sue => sub{$d=$_[0] if @_}; #line 6
  sub hal {$e=$_[0] if @_}                 #line 7
  $bob->(@_);
  sue->(@_);
  hal(@_);
  print "c=$c d=$d e=$e\n";
}

foo("q");
foo();
foo("a");
foo("b");
__END__


output:
------------------------
Variable "$e" will not stay shared at testshared.pl line 7.
c=q d=q e=q
c=x d=y e=z
c=a d=y e=z
c=b d=y e=z

0
a2intl (1)
7/13/2005 6:14:39 PM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

1 Replies
552 Views

Similar Articles

[PageSpeed] 41

Andrew wrote:

> Seems like we're missing the "will not stay shared" warning for anon
> subs declared via "use constant". Is this a bug?

No, you can't expect Perl to detect you shooting yourself in the foot by 
bouncing off three walls.

> Please cc: me on replies.

Post here, read here.
0
Brian
7/13/2005 7:05:43 PM
Reply: