It sounds like to me that you haven't tried any of the things in the Perl book that might answer this question. You do have a Perl book, don't you? I can highly recommend the fine series of books from O'Reilly.
In any event, the variable $. tells you what line you're on, so printing that out after reading through the file would tell you what number the last line of the file was.
#!/usr/bin/perl -w
use strict;
while(<>){}
print "Last line number was $.\n";
If you also want to fine out how many characters there were, you'd add something to count the length of each line:
#!/usr/bin/perl -w
use strict;
my $totalLength = 0;
while(<>){$totalLength += length($_);}
print "Last line number was $.\n";
print "Total length was $totalLength\n";
I haven't tested this code; don't know if it works or not. I'll leave that up to you. Play around. See what works. Read that Perl book. Try stuff, and come ask questions when you get stuck, and not before.
Alex / talexb / Toronto
Life is short: get busy!
|