use strict; my $string = shift; my %seen; foreach (0..(length $string) - 1) { my $temp = $string; substr $temp, $_, 1, ""; print "$temp\n" unless $seen{$temp}++; }