sub nonrepeating { my $word = shift || $_; my %chars; @chars{ split( //, $word)} = (); length($word) == keys %chars; } my @solutions; while () { chomp; push @solutions, $_ if length() == 15 and nonrepeating(); }