On Friday, September 6, 2002, at 08:54 AM, Tobin, Elliot wrote: > I have the following as my data inside a package: > > my $dataBlock = { isInsertable => $isInsertable, > fields => undef,
fields => [ ], # try this instead > requiredFields => undef, > selectionFields => undef, > returnFields => undef }; > > How do I go about storing a list as the value of the > $dataBlock->{'fields'} > key? You need to use an array reference. The above creates a reference to an empty array. > > I'd like something like the following to work: > > sub setFields > { > my ($inBlock, @fieldList) = @_; > > foreach my $i (@fieldList) > { > push($inBlock->{'fields'}, $i); push(@{ $inBlock->{'fields'} }, $i); # then push onto the array at the end of the ref > } > > return $inBlock; > } > > I understand it won't because $inBlock->{'fields'} is not an array... > Any > help would is appreciated. > > TIA, > > EllioT When you later need to get something back out, it's as easy as: $dataBlock->{'fields'}[$index_to_get] Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]