> I am trying to create a script that read a > file and count consonnant then output the > results to another file. I would ask here > if anybody can help me to write the script.
Does this sound like homework or what? > 1. the c at the end of words > 2. the cc at the end of words > 3. the cing at the end of words > 4. the ccing at the end of words > > Input file > danc <1> danccing <2> > dancc <2> danccing <2> > danc <1> dancing <1> > danccing <2> danc <1> > dancing <1> dancc <2> sub count { my $line = shift; my @count; foreach (split /\s+/, $line) { $count[0]++ if /c$/; $count[1]++ if /cc$/; $count[2]++ if /cing$/; $count[3]++ if /ccing$/; } return @count; } my @count = count('danc <1> danccing <2>'); foreach my $rule (0..3) { print "Rule #" . (rule + 1); print $count[$rule]; } __END__ <RANT = "HOMEWORK EXERCISES"> Please do not submit homework questions to mailing lists such as this one. Reading your lecture notes, books and ask help from tutors. If you aren't able to complete the homework yourself without assistance you either need to change course or work harder. Besides, studing and doing it yourself is FAR MORE benefical and rewarding. </RANT> Jonathan Paton __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]