#!/usr/bin/perl -w use strict; my @strings = qw(johnny cash willie nelson); my $pos = 0; for my $i (0..$#strings) { my @tmp = split ('', $strings[$i]); $tmp[$pos] =~ tr/jcwn/cjnw/; $strings[$i] = join ('', @tmp); } print "@strings\n"; #### #!/usr/bin/perl -w use strict; my @strings = qw(johnny cash willie nelson); my $pos = 0; for my $i (0..$#strings) { substr($strings[$i],$pos,1) =~ tr/jcwn/cjnw/; } print "@strings\n";