I want to convert each letter in a sentence to a certain letter depending on if it is a consonant or a vowel, where vowels are AEIOU.
So if I have a string
$string = 'Hello'
I would like to see
$string = 'CVCCV'
As a result.
I know I can use:
$string =~ s/A/V/
$string =~ s/B/C/
$string =~ s/C/C/
and so on to check and convert each letter individually, but surely there must be a more efficient way to do this.
normalize case, then apply the transliteration operator:
$string = lc $string;
$string =~ tr/aeioua-z/VVVVVC/;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With