in reply to two regexes in one function call
#Prints 2,6,34use 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");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: two regexes in one function call
by bobr (Monk) on Jul 28, 2009 at 16:23 UTC |