in reply to Search PCL file
Can you show a short segment (10 lines or fewer) of your PCL file? I'm not sure what a PCL file is or what it looks like.
It would also be helpful if you show us how you are trying to use pos and index.
Your "get" sub looks like it's just counting the number of lines on which a certain string occurs. Another way to code this is:
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; }
|
|---|