in reply to pattern match a name from stdin

You add chomp($file).

print "$num_entry\n";

Also you are printing $num_entry which is not declared or used anywhere, check it.

Curly brace missing in your coding.

You coding works fine for me if i add that curly brace.

updated

Regards,
Anniyan
(CREATED in HELL by DEVIL to s|EVILS|GOODS|g in WORLD)