Help for this page

Select Code to Download


  1. or download this
     use strict;
     use warnings;
    
  2. or download this
     my $fpath = '/somewhere/in';
     my $fname = 'input.dat';
     my $fn = "$fpath/$fname";
     
     die "$fn: $!" unless -f $fn;
    
  3. or download this
     my $content;
     {
    ...
        local $/;
        $content = <$fh>;
     }
    
  4. 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;
    
  5. or download this
     for my $key (sort keys %counts) {
        print "$key ==> $counts{$key}\n"
     }