in reply to Creating an array of structures?

You want a hash:
my %foo = ( name1 => type1, name2 => type2, name3 => type3, name4 => type4, ); print $foo{name2}, "\n";
Se "perldoc perldsc" if you need more complicared structures.

Update: Oops I mostly copied the OP. Changed as suggested by davido. Note to self : dont post at 7 AM.

Replies are listed 'Best First'.
Re^2: Creating an array of structures?
by davido (Cardinal) on Mar 08, 2005 at 06:09 UTC
    my %foo = ( name1, type1; name2, type2; name3, type3; name4, type4 ); print $foo{name2}, "\n";

    I realize that's probably just pseudo-code, but we ought to get the syntax right anyway. :)

    my %foo = ( name1 => 'type1', name2 => 'type2', name3 => 'type3', name4 => 'type4' ); print $foo{name2}, "\n";

    In particular, note the use of ',' (comma) instead of ';' (semicolon) between list items.


    Dave