Jump to content

Count how many vowels and consonants occur in a string: Difference between revisions

Line 188:
5 vowels and 13 consonants (distinct)
22 vowels and 31 consonants (total)</pre>
 
=={{header|Perl}}==
<lang perl>#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Count_how_many_vowels_and_consonants_occur_in_a_string
use warnings;
 
while( <DATA> )
{
print "@{[ $- = tr/aeiouAEIOU// ]} vowels @{[ tr/a-zA-Z// - $-
]} consonants in: $_\n"
}
 
__DATA__
test one
TEST ONE
Now is the time for all good men to come to the aid of their country.
Forever Perl Programming Language</lang>
{{out}}
<pre>
3 vowels 4 consonants in: test one
 
3 vowels 4 consonants in: TEST ONE
 
22 vowels 31 consonants in: Now is the time for all good men to come to the aid of their country.
 
11 vowels 19 consonants in: Forever Perl Programming Language
 
</pre>
 
 
=={{header|Phix}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.