Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Sigils are hard to teach . . . very useful once you get someone to understand them, but that first step can be hard.

So why not get rid of them? That's what I set out to do, but instead wound up with STUPID (Sigils Turned Unified . . . uh . . . PID). STUPID will turn all four of Perl's sigils to the ampersand: &. You must assign to these variable in a more Python/Ruby - ish idiom, much like constructing anonymous arrays and hashes. In fact you are. They no londer interpolate in double quoted strings, and the implementation doesn't always work, AND you have to explicity dereference arrays/hashes. I couldn't think where this should really belong, but I figured this was the closest place in the Monestary. Enjoy, and don't take seriously.

sub AUTOLOAD : lvalue { (!ref ${$AUTOLOAD}) ? ${$AUTOLOAD} : (!wantarray) ? ${$AUTOLOAD} : (ref ${$AUTOLOAD} eq 'ARRAY' +) ? @{${$AUTOLOAD}} + : %{${$AUTOLOAD}}; }
Cheers,
Erik

ps. Yes I am aware that it uses sim-refs . . . it's just a joke man :-)

pps - Here's how to use this little gizmo . . .

#include AUTOLOAD from above . . . &foo = ['a', 'b', 'c']; print &foo->[0];

UPDATE:

Alright! I don't know if anyone will ever read this, but just in case, it should be noted that Perl 5.8 fixes the problem with lvalue AUTOLOAD which required that you use the & funny character. Now this little snippet truly eliminates sigils entirely. I think. I actually haven't been able to test it, 'cause my computer is broken. /msg me if it works


In reply to One Sigil to Hack them All . . . by erikharrison

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found