sol1.pl (325B) [raw]
1 #!/usr/bin/env perl 2 use strict; 3 use warnings; 4 5 open(my $fh, '<', 'input') or die "$!"; 6 my $n; 7 for my $line (<$fh>) { 8 chomp $line; 9 my ($min, $max, $goal, $pass) = $line =~ m{^(\d+)-(\d+) ([a-z]): ([a-z]+)}; 10 my $count = () = $pass =~ /$goal/g; 11 if ($count <= $max && $count >= $min) { 12 $n++; 13 } 14 } 15 print "$n\n";