Thread: Matching definite articles etc
Results 1 to 1 of 1
Related
-
Matching Case Forum: PHP Forum
Replies: 2 -
Simple Pattern Matching help Forum: CGI Perl Forum
Replies: 3 -
Pattern Matching Forum: CGI Perl Forum
Replies: 1 -
Matching a certain date format from a String? Forum: CGI Perl Forum
Replies: 0
-
11-02-2006, 09:55 AM #1
Matching definite articles etc
I am trying to count all the definite articles and indefinite articles. And change "the"=>"THE", "a"=>"A", "an"=>"AN".
Obviously, a lot of errors in my codes.
Hopfully, to get help
perl test.pl test.txt
Code:use English; my $def_count; # the number of definite articles my $indef_count; #the number of indefinite articles sub count { if ( $ARG[0] =~ /the/) #count as true if the lowercase version of the only argument of count is equal to "the" { $def_count++; } else { $indef_count++; } return /uc($ARG[0])/; # return the uppercase version of the only argument of count. } while (<>) { s/b\([Tt]he|a|an)\b/uc($1)/ #output the line here,but how to do it } print "\nThere were $def_count definite articles\n", "and $indef_count indefinite articles in the text.\n";
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum