#!/usr/bin/perl use strict; use warnings; my $file = $ARGV[0] or die "Usage: $0 "; open(my $fh, '<', $file) or die "Unable to open '$file' for reading: $!"; my ($line_cnt, $word_cnt, $char_cnt); while (<$fh>) { chomp; $line_cnt++; $char_cnt += length($_); my @word = split " ", $_; $word_cnt += @word; }