in reply to Search PCL file

Please remove the "br" tags from your original posting, then enclose your code in "code" tags, as described in Writeup Formatting Tips.

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; }

Replies are listed 'Best First'.
721928
by mike1977 (Initiate) on Nov 06, 2008 at 09:49 UTC