http://qs321.pair.com?node_id=178515

dinesh has asked for the wisdom of the Perl Monks concerning the following question:

hi i want to know wheather we can build an array which will acta s an hash at runtime it is possible otherwise in versions 5.005 and above using the syntax
{key1=>arrayindexvalue1, key2=>arrayindexvalue2,..... }
for example
$arrayreference = [{first =>1,second =>2 } , "hello ","there"];
now this will work both as an array and a hash
print " $arrayreference->{first} \t $arrayreference->{second} \n"; >hello there print " $arrayreference->[1] \t $arrayreference->[2] \n"; >hello there
can i build this thype of array at runtime that is can i add elements to this array one by one rather than initializing them all at one time

thanks

dinesh

edited: Mon Jul 1 13:29:48 2002 by jeffa - added code tags