# Create ARRAYref to list of 7 elements, with first element "", # remaining 6 elements copied from @fields. $file2{$id}=["",@fields]; $file3{$id}=["",@fields]; ... # trying to access 6th element of $file2{$id} as a list, but it's # an ARRAYref to a list with 7 elements... my @fields2=$file2{$id}[5]; my @fields3=$file3{$id}[5]; #### # just hang onto the ARRAYref returned from $csv->getline(), # unless it doesn't want us to. $file2{$id}=$row; $file3{$id}=$row; ... # You really did want the 6th column, right? my $fields2=$file2{$id}->[5]; my $fields3=$file3{$id}->[5]; #### # Create list with one element as a string concat looking like # "ARRAY(0x141ecf8)\tARRAY(0x141edd0)\tARRAY(0x141ee48)" my @printline= ( $fields_ref."\t".\@fields2."\t".\@fields3; $csv->print ($FILE4,\@printline); #### # List with 8 elements my @printline= ( @fields, $file2{$id}->[5], $file3{$id}->[5] ); $csv->print ($FILE4,\@printline);