in reply to count number of pages in two datafiles
my @lines = `wc -l $data_file`; @lines[0] =~ /(\d+)\s/; my $linecount = $1;
I know less about windows boxes, but you can still always open the file and read through it, adding up the number of lines as they go by:
Easy enough, though I suspect there may be a better way.my $linecount=0; open FILE, $data_file; while (<FILE>) { $linecount++; } close FILE;
Scott
Updated wc to get only the number.
update2: It's funny how it's always the simple questions: one thing that occurred to me is that this assumes there are no lines that will wrap on printing. If that is a good assumtion, fine. If not, code will have to be added to check the length of the line. If it is long enough to wrap, $linecount should be incremented by 2.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: count number of pages in two datafiles
by data67 (Monk) on Aug 23, 2001 at 18:47 UTC | |
by scain (Curate) on Aug 23, 2001 at 18:53 UTC |