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

Maybe a bug in stricture? Short test case.

From:
Clinton A. Pierce
Date:
September 20, 2000 20:09
Subject:
Maybe a bug in stricture? Short test case.
Message ID:
200009210307.XAA07570@budman.backroom
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" };
	&$r;

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.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About