http://www.perlmonks.org?node_id=291214


in reply to Undocumented variable?

As the other poster says, all punctuation has a certain amount of magic. Even if a given punctuation variable doesn't have any specific magic, it still has the general magic that applies to all of them. If you read the obfuscation section from time to time, you'll see people using punctuation characters to name not just scalars and arrays but also hashes. Certain punctuation characters are particularly popular for this, most notably underscore and semicolon. (%; makes for some good fun, particularly. $_{$_} is also interesting in the right combinations.) _ is also a legal name for a subroutine, though I'm not sure there's any magic in that case.

I believe the reason all punctuation variables are automatically magical is a combination of consistency and implementation details, but frankly it shouldn't be a problem in most cases, because if you don't want weird stuff to happen you shouldn't use weird variables; there are plenty of letters in the alphabet, after all, if you're a fan of the mundane.

In Perl 6, some of the special punctuation variables will be going away or changing, but the default arg is getting extended. In Perl5, $_ and @_ have special magic, but %_ is only magical in the general way; in Perl6, %_ will have special magic, as well. (I believe L.W. is using the term 'topic' for this.)

Another difference in Perl6: in Perl5, all punctuation variables are global. You can scope them dynamically (with 'local'), but you cannot scope them lexically (with 'my'). In Perl6, you will be able to scope them lexically (err, whichever ones are kept, that is; as I said, some of them are going away or getting changed, renamed, or otherwise adjusted).


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/