$ perl -MO=Deparse -le"%h=(), undef @h{split'',$_}, keys %h == 3 and print for '0000'..'9999'" BEGIN { $/ = "\n"; $\ = "\n"; } ; (%h) = (), undef @h{split(//, $_, 0)}, keys %h == 3 and print $_ foreach ('0000' .. '9999'); -e syntax OK