in reply to New perl student... feeling stupid
firstly just declare the hash
Now where you have $para++;$sen++;$vow++; replace them with$count{'para'}++; etc....my (%count);
Finally in your print statement you need both the key (para,sen,vow)
and the values (2,5 ,whatever )so replace print "$value";
with print "$value : $count{$value};
You should probably replace the $value with $key because it
is misleading (it actually is the key and not/ the value.
What you were doing was creating 3 new variables which had nothing to do with your script.
I just had a look at the rest of you script and it's a bit of a mess :-) I dont have time now but here's how I would count the sentences and vowels
Diarmuidundef $/; while(<>){ my @chars=split(//,$_); foreach my $char (@chars) { $count{'vow'}++ if(/[aeiou]/); $count{'sen'}++ if(/\./); }
|
|---|