I'm trying to capitalize 3 and 4 letter words that contain only vowels or consonants, but not both. The code I've come up with is not working correctly. Given the string 'The Kcl Group', it should return 'The KCL Group' but it is also capitalizing the word 'THE'. What am I doing wrong?
Thanks, Marc use strict; use warnings; my $string = 'The Kcl Group'; my @words = split(/ /, $string); my @new_words; foreach my $word (@words) { if ((length $word >= 3 and length $word <= 4) and ($word !~ m/[aeiouy]+/gi or $word !~ m/[bcdfghjklmnpqrstvwxz]+/gi)) { $word = uc($word); } push @new_words, $word; } $string = "@new_words"; print $string . "\n"; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/