Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Obfuscated accessor

by bluescreen (Friar)
on Jan 27, 2009 at 20:16 UTC ( #739329=snippet: print w/replies, xml ) Need Help??
Description: I was thinking if there any chance to write an accessor in just one line, and I came up with the following code. Of course I wouldn't use in a real project because its unreadable but it might worth sharing. The good thing is just replacing subroutine name creates a new accessor.
sub methodA { $_ = (caller(0))[3];s/.*\://; @_ > 1 ? $_[0]->{$_} = $_[
+1] : $_[0]->{$_} };
Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://739329]
help
Chatterbox?
[erix]: ha, good stuff - loud and fast...
[stonecolddevin]: here's some Mastodon for when you have 13 minutes to have your mind blown: https://www. youtube.com/watch? v=4pvfQtUhtNE
[karlgoethebier]: goes to Brownsville one more time..
erix squirrels away the linkies

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2017-06-22 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.