while(){ if(/GET\s.*\/(\S+)\.pdf\s/i and exists $file_counts{$1}){ $file_counts{$1}[0]++; } }