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. |