in reply to Counting occurances of a pattern in a file

There are a lot of problems. You read multiple lines from the file, you close() inside the while() loop, .... Here's what you want:
while (<INPUT>) { $n++ if /^Algorithm/; last if /^Experiment Name/; } close INPUT;
Cheers;

Nat