How can I count paragraphs in text file using Perl?
Posted
by robjez
on Stack Overflow
See other posts from Stack Overflow
or by robjez
Published on 2010-03-14T19:14:45Z
Indexed on
2010/03/22
2:01 UTC
Read the original article
Hit count: 375
I need to create Perl code which allows counting paragraphs in text files. I tried this and doesn't work:
open(READFILE, "<$filename")
or die "could not open file \"$filename\":$!";
$paragraphs = 0;
my($c);
while($c = getc(READFILE))
{
if($C ne"\n")
{
$paragraphs++;
}
}
close(READFILE);
print("Paragraphs: $paragraphs\n");
© Stack Overflow or respective owner