Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How's your Perl?

by ambrus (Abbot)
on Jun 08, 2005 at 09:32 UTC ( #464608=note: print w/replies, xml ) Need Help??


in reply to How's your Perl?

Here's a new solution for question 3a. This is not strict in the sense that you have to turn off strict for the set-up code to work. However, the actual test \$foo->[1] == \$foo->{1} runs under strict, unlike in my original symbolic ref solution.

I think that this solution differs from all the solutions given so far, so I submit it even though this puzzle is now quite old.

$R = "Regexp::"; *{"$R(\@{}"} = sub { &{sub{\@_}}(2,$t{1}) }; *{"$R(%{ +}"} = sub { \%t }; *{"$R()"} = sub {}; ${"${R}OVERLOAD"}{$(}--; our $ +foo = qr/a/; use strict; \$foo->[1] == \$foo->{1} or die;

And for super-search purposes, this solution uses operator overloading on the Regexp package.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2023-11-29 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?