use strict; use warnings; print "Packs returned:", get('foo.pcl'), "\n"; sub get { my $data_file = shift; my $count = 0; open my $fh, '<', $data_file or die "Could not open file: $!"; while (<$fh>) { $count++ if /1 of/; } close $fh; return $count; }