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

A

Andrew

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
 
B

Brian McCauley

Andrew said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top