develooper Front page | perl.perl5.porters | Postings from September 2000

Maybe a bug in stricture? Short test case.

Clinton A. Pierce
September 20, 2000 20:09
Maybe a bug in stricture? Short test case.
Message ID:
I think I may have found a bug -- or at least a loophole --
in the strict pragma.  Observe:

	#!/usr/bin/perl -w

	use strict;
	sub test {
		print "Got here";
	my $c="test";
	my $r=\&{ "main::$c" };

Now it did what I wanted, namely it allowed me to use a string as 
a subroutine name (hey, I was still asleep at the time).  But I 
half-expected to wrap this in a "no strict" to get it to work.  
Suprisingly it did anyway.  Under 5.005 and under 5.6.

If this is not a bug, can someone please explain how this
works without getting trapped by strict somehow?  If it's a bug,
please don't fix it as I have code that now relies on this 
behavior. :)

This was also sent to perl-friends earlier without response,
so if this is a duplicate to you...too bad. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About