> -----Original Message-----
> From: Tobin, Elliot [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 06, 2002 9:55 AM
> To: '[EMAIL PROTECTED]'
> Subject: Arrays inside
>
>
> I have the following as my data inside a package:
>
> my $dataBlock = { isInsertable => $isInsertable,
> fields => undef,
> requiredFields => undef,
> selectionFields => undef,
> returnFields => undef };
>
> How do I go about storing a list as the value of the
> $dataBlock->{'fields'}
> key?
>
> I'd like something like the following to work:
>
> sub setFields
> {
> my ($inBlock, @fieldList) = @_;
>
> foreach my $i (@fieldList)
> {
> push($inBlock->{'fields'}, $i);
> }
>
> return $inBlock;
> }
>
> I understand it won't because $inBlock->{'fields'} is not an
> array... Any
> help would is appreciated.
You would need:
push @{$inBlock->{fields}}, $i;
Or, instead of the loop, just do:
$inBlock->{fields} = [ @fieldList ];
The square brackets construct an anonymous array and return a reference to
that array, which is then assigned to the hash entry.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]