And, for increased flexibility (strict/warn OK) my @array = ( 10,20,30,40); my %array = @array;
my %hash = (1,2,3,4); my @hash = %hash; print "Array Element \$array[1] = $array[1]\n"; print "Hash Element \$hash{'1'} = $hash{'1'}\n"; print "Array Hash Element \$array{'10'} = $array{'10'}\n"; print "Hash Array Element \$hash[1] = $hash[1]\n"; Enjoy! > -----Original Message----- > From: Lance Murray [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 18, 2002 11:02 AM > To: [EMAIL PROTECTED] > Subject: Confusion on @array vs $array[] vs $array > > Hello: > > I have been fairly confused on the intermixing of array naming standards. > If I > understand correctly, the @array syntaxt is used to refer to the whole > array, > while $array[n] is refered to specific elements. > > In my thinking, it would have been less confusing to use @array[n] to > address > specific elements, but Perl complaines bitterly when warnings &/or strict is > enabled. > > Is the rational for the "$"array[] character for identifying "@"array > elements > due to the fact that the $ character has special meaning (denotes variable > or > element) within double quoted text, while the @ sign has no special meanign > within double quotes. > > Anyway, perhaps one of you syntactical thought police could give me some > insights to the rational. I find it very confusing that the $ and @ > characters > are supposed to be used interchangeably to denote arrays, particularyly when > I'm > trying to fathom the relation to other issues such as scalar or list > context. > As I recall, hashes arso use % and @ interchangeably. > > Thanks, > > Lance > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]