@cols[1 .. $#cols] = map(tr /[1,2]/[0,1]/, @cols) #### my %data; while () { next if /^id/; my ($id, @cols) = split; ## first split my $cols = join('',@cols); ## Join @cols = split('',$cols); ## and then split push @{ $data{$id} }, \@cols; }