while (<DATA>) { my ($key, $mask, $src) = split; my @mask = $mask =~ /./g; my @src = $src =~ /.../g; print "$key: "; print $_ eq '-' ? '---' : shift @src for @mask; print "\n"; }
__DATA__ cat mfgdhf agtcatgcacactgatcg dog mfg--f agtcatgcatcg mouse mf-d-f agtcatcactcg
I see that you also made use of arrays. It struck me that, since the starting point is strings and not lists, using substr() would be more straight-forward:
my %hash3; for ( keys %hash1 ) { while ( my $aa = substr $hash1{$_},0,1,'' ) { $hash3{$_} .= $aa eq '-' ? '---' : substr $hash2{$_},0,3,''; } }
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>