in reply to Opening file and checking for data

Grep would probably be a better way to do this.
my $count = grep /match/, <DATA>; print $count; __DATA__ match123123 match3123 nomat not34234 match 4232434
This outputs 3.
or my golfing solution(a little shorter):
print scalar(grep /match/, <DATA>);

Update: Fixed my grammar.