use strict; use warnings; sub countIt { my $data = shift; my $lines =()= $data =~ /\n/g; $lines++ unless $data =~ /\n$/; # Last line may not have \n on it my $words =()= $data =~ /\w+/g; my $length = length($data); return ($lines, $words, $length); } print join ',', countIt(" Blah blah blah\nStuff-by:somebody");