my $count = 0; while(<>) { $count+= () = m< photo/([a-z]+\.[a-z]{3}) >gxi; }