Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Undocumented variable?

by jonadab (Parson)
on Sep 13, 2003 at 04:08 UTC ( #291214=note: print w/ replies, xml ) Need Help??


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$/


Comment on Re: Undocumented variable?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://291214]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-11-26 20:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (173 votes), past polls