#!/usr/bin/perl -w use strict; my $string; while ( <> ) { $string .= $_; } $string =~ s/\s+//g; print length($string), "\n";