in reply to perl prog to read a sentence and print the count of chars for each word
use 5.010; say "Enter a sentance:"; say join q{ }, # join each with a space, and say map { length $_ } # find length grep { $_ } # ignore zero-length map { s{\W}{}g; $_ } # strip out non-word characters split m{\s+}, # split on whitespace do { my $line = <> }; # read a line __END__ Enter a sentance: A man, a plan, a canal: Panama 1 3 1 4 1 5 6
|
|---|