By using length($_), this should give you a good count. You are not chomping the input, so it will return the linefeed(carriage return).
Wags ;) -----Original Message----- From: Marcus Willemsen [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 09:30 To: [EMAIL PROTECTED] Subject: Counting every character in a textfile Hi all, I'm trying to figure out how to count characters in a textfile. The count has to include all letters, numbers, non-letters, whitespaces, newlines tabs, etc. I was thinking about something along the lines of: #!/usr/bin/perl -w use strict; my $count = 0; my $text = 'c:\marcus\temp\bonn.txt'; open(TEXT, $text) or die "Konnte $text nicht öffnen"; while(<TEXT>) { if(/[\d\D]/){ $count++ } } print $count; But it doesn't work and I don't know why. As far as I understood [\d\D] is supposed to match every number and every non-number including newlines. Marcus Willemsen Online Redaktion Juve Verlag Agrippastr. 10 50676 Köln tel: ++49(0)221 91 38 80 16 fax: ++49(0)221 91 38 80 18 www.juve.de [EMAIL PROTECTED] [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]