in reply to Deprecated Syntax in 5.8

I had previously posted: @a->.. and %h->{...} are described in perldsc Data Struct Cookbook
My original posting is wrong, and I have been corrected. (even humbled)... I apologize if I pointed someone in the wrong direction. Since I had no idea what the syntax was I was GUESSING that it might be another way to reference varibles in anonymous structures. previous self-pity stuff removed too

Replies are listed 'Best First'.
•Re: Re: Deprecated Syntax in 5.8
by merlyn (Sage) on Dec 16, 2002 at 21:31 UTC
    @a->... and %h->{...} are described in perldsc Data Struct Cookbook.
    No they aren't. They've always been conceptually illegal syntax. The problem is, up to 5.8, their illegality hadn't been enforced by the compiler, and so people who just throw random things together (rather than understanding what they're doing) ended up taking advantage of the lack of syntax checking.

    @a->[$foo] is correctly written $a[$foo], while %h->{$bar} is correctly written as $h{$bar}. No references involved at all.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: Re: Deprecated Syntax in 5.8
by djantzen (Priest) on Dec 16, 2002 at 21:37 UTC

    But your example structures aren't anonymous; if they were they wouldn't have names e.g., a and h! An anonymous structure is declared like:

    my %hash = (); $hash{foo} = [qw/bar/];

    Here foo in %hash points to a reference to an anonymous array containing bar.

    Another common usage is in parameter passing:

    sub some_func { my $args = shift; } some_func( { foo => 'bar' } );

    Here an anonymous hash is created to hold the function arguments, which is then referred to by the scalar $arg inside the subroutine.

    I couldn't find the section you were referring to in perldsc. Can you be more specific?

    Update: clarified second example; the scalar $arg contains a reference to the anonymous hash.