Today around 2:47pm, Jerrad Pierce hammered out this masterpiece:
: That's pretty damn nifty, too problems though:
Thanks :-)
: print SCALAR $hashref->{key}, "\n";
: is bogus, SCALAR eats the newline as an argument.
: Granted this could be fixed with parens, but somehwat disappointing.
Yep, we actually never got that far in code, be know about the problem.
: In this context it's hard to tell if SCALAR is a handle or a function
: (again parens are the solution).
We couldn't say. I call it a 'thingy', see below.
: I was unable to conceive of a way to allow the {}. You get a hash ref
: back, which when dereferenced %{} contains your reference.
: That, when dereferenced returns nothing.
That's because the pragma had to read the program and modify it, before
executing it and exiting. Now that is a hack if I ever head of one.
so:
ARRAY{ $hashref->{key} }
get's munged into:
@{ $hashref->{key} }
with some sofisticated regex ops before being executed.
Now, as a pragma, this looks ugly and nasty. If this were in the perl core, it
would be less nasty I would imagine.
: sub ARRAY {
: return @{ shift() };
: }
:
: sub SCALAR {
: # my $ref = shift();
: # if( ref($ref) eq "HASH" ){
: # $ref = (each %{$ref})[0]; }
: # return ${ $ref };
: return ${ shift() };
: }
:
: $hashref = {
: scl=>\value,
: ary=>[1,2] };
:
: print SCALAR $hashref->{scl};
: print "\n";
: print join(',', ARRAY $hashref->{ary}), "\n";
:
--
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'[EMAIL PROTECTED]',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>