foreach (@d) { $template=/^.*\.[^.]+/ if(/$count/); }