#!/usr/bin/env perl use warnings; use strict; my $count = 0; opendir my $dh, '.' or die "$!\n"; while (defined(my $entry = readdir($dh))) { $count++ if ($entry =~ /^246.56/); } closedir $dh; print "count=$count\n";