- or download this
use strict;
use warnings;
- or download this
my $fpath = '/somewhere/in';
my $fname = 'input.dat';
my $fn = "$fpath/$fname";
die "$fn: $!" unless -f $fn;
- or download this
my $content;
{
...
local $/;
$content = <$fh>;
}
- or download this
my %counts;
$counts{CHARS} = length $content;
$counts{WORDS} = scalar( () = $content =~ /\b/g ) / 2;
$counts{SENTN} = scalar( () = $content =~ /\w\.\W/g );
$counts{PARAS} = scalar( () = $content =~ /\n/g ) + 1;
- or download this
for my $key (sort keys %counts) {
print "$key ==> $counts{$key}\n"
}