#!/usr/bin/perl use strict; use warnings; PIN: foreach my $pin ("0000" .. "9999") { # Last digit is a 1 next unless $pin =~ /1$/; # No repeating digits my %count = (); foreach my $digit (split(//, $pin)) { $count{$digit}++; next PIN if $count{$digit} > 1; } print $pin . "\n"; }