in reply to SOLVED Removing characters
Outputsuse strict; use warnings; my $lines = 0; my $mystring = ''; my $chars = 0; my $word_cnt = 0; while(<DATA>) { my $str = $_; $chars += length($str); $lines++ ; my @words = grep /\w/, ($str =~ /\b\w*\b/g); $word_cnt += $#words + 1; $str =~ s/( |,|\.|\n|\t)//g; $mystring .= lc($str); } print "Lines: $lines\n"; print "Words: $word_cnt\n"; print "Characters: $chars\n"; print "Total String: $mystring\n"; __DATA__ The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
Lines: 4 Words: 36 Characters: 180 Total String: thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumps +overthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjump +soverthelazydog
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Removing characters
by Slug (Acolyte) on Jan 22, 2008 at 15:42 UTC |