Presumably, you have some definition of the number of lines that
corresponds to a page. If you are on a unix box, you can
get the number of line with wc:
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:
my $linecount=0;
open FILE, $data_file;
while (<FILE>) {
$linecount++;
}
close FILE;
Easy enough, though I suspect there may be a better way.
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.