sub getExpNumber { my $filePath = shift; my $n; open (INPUT,"<$filePath") or die "Can't open $filePath: $!\n"; while () { chomp; last if /^Experiment Name/; $n++ if /^Algorithm/ } print "There are $n experiments in $filePath\n" close(INPUT) or die "Can't close $filePath: $!\n"; return $n; }