in reply to What's the exact rule about hash/pound?

Comments are anything starting with an unquoted #, or a # character that's not part of a term.

%# = ( foo => 'bar', baz => 'buz' ); print keys( %# ), "\n";

Unfortunately, you can't access an element of that hash directly because it looks like you want the last element of an array. Bug? Maybe, but I sure don't want to fix it.

Update: Oh yeah, but yuck.

Replies are listed 'Best First'.
Re: Re: What's the exact rule about hash/pound?
by IlyaM (Parson) on Feb 27, 2003 at 07:57 UTC
Re: Re: What's the exact rule about hash/pound?
by ihb (Deacon) on Feb 27, 2003 at 21:05 UTC

    IlyaM has said how to do it right, so I figured I will say how to do it wrong. :)

    This is bad, ugly, and deprecated*, but it works:   %#->{foo} If you want to stay legal you can do it semi-direct:   (\%#)->{foo} While on the theme of references:

    no strict 'refs'; '#'->{foo}
    which will work since %# can't be private.

    But don't do any of the above.

    ihb

    * It's labeled as a "known problem" in perl561delta, but in perl580delta it's called deprecated.