#!/usr/bin/perl use strict; use warnings; use Algorithm::Loops 'NestedLoops'; use Text::Levenshtein 'fastdistance'; my $seed = $ARGV[0] || '000'; my $iter = NestedLoops([([0..3]) x length($seed)]); while (my @list = $iter->()) { my $neighbor = join '', @list; print "$neighbor\n" if fastdistance($neighbor, $seed) < 3; }