>-----Original Message-----
>From: Marc [mailto:sono...@fannullone.us]
>Sent: Thursday, September 08, 2011 9:58
>To: Perl Beginners
>Subject: Capitalizing Acronyms
>
>
>       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)) {

        I changed the following:
($word !~ m/[aeiouy]+/gi or $word !~ m/[bcdfghjklmnpqrstvwxz]+/gi)
        To
 ! ($word =~ m/^[aeiouy]+&/gi or $word =~ m/^[bcdfghjklmnpqrstvwxz]+&/gi)
        This forces a start and end of on $word and I like the positive of if 
ONLY vowels plus Y or ONLY consonants. SO it is one way of doing it.

         If you have any questions and/or problems, please let me know. 
         Thanks. 
 
Wags ;) 
David R. Wagner 
Senior Programmer Analyst 
FedEx Services 
1.719.484.2097 Tel 
1.719.484.2419 Fax 
1.408.623.5963 Cell
http://Fedex.com/us



>               $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/
>


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to