in reply to Mapping to an associative hash

Your records have tab-delimited fields, so "@tmp = split /\t/;" copies those fields, in order, into the array.   Are the fields named in the same order you show in %import_data, that is, is the 'id' value first, then the 'username' value, and so on?   You just need to stuff name/value pairs into your hash using names in the same order as your values.

my @field_names = qw( id username domain .... prime_phones ); my @field_values = split /\t/; @input_data{@field_names} = @field_values;
That's using a "hash slice".   A longer parallel version (untested)
my @field_names = qw( id username domain .... prime_phones ); my @field_values = split /\t/; for( my $i=0; $i<@field_values; ++$i ) { $input_data{$field_names[$i]} = $field_values[$i]; }

Replies are listed 'Best First'.
Re: Re: Mapping to an associative hash
by THRAK (Monk) on Sep 17, 2003 at 13:04 UTC