I'm not sure what u mean by identifying by each line, do you want to be able
to seek or something?

I can think of a few ways to do a line count.  Maybe one of these will get it.

$count = `cat $file | wc -l`;   #degenerate way.. ;)

open(FILE, "$file");
binmode FILE;
undef $/;
$data = <FILE>;
$count = tr/\cJ/\cJ/ $data;

open(FILE, "$file");
binmode FILE;
@data = <FILE>;
$count = scalar @data;

open(FILE, "$file");
binmode FILE;
$count = 0;
while (read FILE, $buffer, 32768) { #32768 or whatever ur cluster sz is
        while ($buffer =~ m/\cJ/g) { $count++ }
}


At 09:38 AM 6/23/05 +0100, Eric  Vercelletto wrote:
>Hi folks,
>
>although the answer seems simple, I have a strange phenomenon while reading 
>a text file, where I want to identify each
>line by its linenumber






--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede males"

00000100

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to