#!/usr/bin/perl use strict; while () { chomp; if ( length() == 9 and not ( /[^0-8]/ or /(.).*\1/ )) { print "$_\n"; } else { warn "rejected input: $_\n"; } } __DATA__ 01234 123456780 1234567890 223456781 345678012 234567890 a12345678 012345678 456782011 456782013 #### while () { chomp; if ( length() == 9 and not /[^0-8]/ ) { my %c = map { $_ => undef } split //; if ( keys %c == 9 ) { print "$_\n"; next; } } warn "rejected input: $_\n"; }