http://www.perlmonks.org?node_id=970297


in reply to Short version of database push for multiple variables

Maybe something like this (if I understand your "append them to corresponding list" correctly):

#!/usr/bin/perl -w use strict; my (@a, @b, @c, @d, @e, @f, @g); while (my $Line = <DATA>) { my @v = split(/\t/, $Line); for my $ar ( \(@a, @b, @c, @d, @e, @f, @g) ) { my $v = shift @v; $v = "NA" unless $v =~ /([A-Za-z0-9-_]+)/; push @$ar, $v; } } use Data::Dumper; print Dumper \(@a, @b, @c, @d, @e, @f, @g); __DATA__ a b c d . f g A B C . E F G

Output:

$VAR1 = [ 'a', 'A' ]; $VAR2 = [ 'b', 'B' ]; $VAR3 = [ 'c', 'C' ]; $VAR4 = [ 'd', 'NA' ]; $VAR5 = [ 'NA', 'E' ]; $VAR6 = [ 'f', 'F' ]; $VAR7 = [ 'g ', 'G ' ];