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

RE: RE: Postfix, whole-object dereference operators

by cwest (Friar)
on Jul 21, 2000 at 19:21 UTC ( #23598=note: print w/replies, xml ) Need Help??

in reply to RE: Postfix, whole-object dereference operators
in thread keys function question

I think he's directly refering to the situation where you have a few references in a row, particularly in hashes... I too, think this is ugly:
and you can't do this:
so, I think it's a gripe about the ugly looks of the syntax. IMHO, I don't mind it, I consider it something like "Variable Encapsulation" in syntax. However, I could see a secondary syntax, as a prefix.


print foreach HASH $obj->{param}; # or we don't like barewords print foreach 'HASH' $obj->{param}; # or parhaps it's really in a prag +ma use dereference qw/HASH/; print foreach HASH $obj->{param}; # or it stays the same print foreach %{$obj->{param}};

Replies are listed 'Best First'.
RE: RE: RE: Postfix, whole-object dereference operators
by japhy (Canon) on Jul 21, 2000 at 19:38 UTC
    The pragma would have to be very magical, since it's a waste to return a potentially LONG list, like an array or hash, and functions like each() and keys() and values() and push() and pop() (etc) require ACTUAL hashes or arrays in their first argument, not things RETURNING them.

    As for %{$ref->[0]->{param}->1->{name}} being ugly, ADD WHITESPACE, and REMOVE ARROWS:
    %{ $ref->[0]{param}[1]{name} }
RE: RE: RE: Postfix, whole-object dereference operators
by japhy (Canon) on Jul 22, 2000 at 02:01 UTC
    I've written a preliminary version of this pragma (it's horrible and ugly, by the way).
    use deref; $href = { 1,2,3,4 }; for (sort keys HASH{ $href }) { print "$_ -> $href->{$_}\n"; }
    I'm working on a second one that doesn't require the { }. It's difficult, because I have to parse perl, and pretty much the only language that can parse perl is Perl. I mean, my first version breaks in places like:
    print "This breaks the HASH{} thing.\n"; # becomes print "This breaks the %{} thing.\n";
    I suppose I could run the code through B::Deparse, but that might break parts of it, which would be A Bad Thing. $_="goto+F.print+chop;\n=yhpaj";F1:eval

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://23598]
and a moth chases the moon...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2018-05-25 01:34 GMT
Find Nodes?
    Voting Booth?