I was reading through a pretty masterful bit of redirection in a recent obfu written by SarahM. (It really is quite nice; I recommend you check it out before reading the spoilers below) Something in it prompted me to wonder about the way perl deals with namespaces of packages, and I was a little confused. I knew what was happening, but I couldn't put my finger on why.
Here's the spoiler to the obfu: SarahM defined a sub q, and later used the builtin q to fool the reader into thinking she was using her own sub. So my question is: under what circumstances does the builtin q// get overridden (assuming one would want to do such a thing)? Is it possible to code the following so that a simple call of q("something") will execute main::q?
sub q { return "inside main sub q"; }
print "Ambiguity gets us the builtin: \n";
print q("not in sub q"), "\n";
print "Let us be more specific: \n";
print main::q("this does not get printed"), "\n";
__END__
Ambiguity gets us the builtin:
"not in sub q"
Let us be more specific:
inside main sub q
LAI
__END__