#!/usr/bin/perl -w use strict; use Data::Dumper; use Carp; # If possible we prefer not to use any CPAN module # or regex. It's for my understanding my $seed = $ARGV[0] || "000"; # Seed can be longer than 3 digits but always 0,1,2,3 for (my $i = 0; $i < length($seed); $i++) { # First loop is to generate 1 position differ for (my $bs=1; $bs<=3; $bs++) { my $bval = $bs; if ( substr($seed,$i,1) == $bs) { $bval = 0; } my $ns = $seed; substr($ns,$i,1,$bval); print "$ns\n"; # Second loop for tags in 2 positions differ for (my $j=($i+1); $j < length($seed); $j++) { for (my $cs = 1; $cs<=3;$cs++) { my $cval = $cs; if (substr($ns,$j,1) == $cs) { $cval = $cs; } my $ns2 = $ns; substr($ns2,$j,1,$cval); print "\t$ns2\n"; } } }