paragkalra has asked for the wisdom of the Perl Monks concerning the following question:
I want to find words containing at least 3 vowels. This is what I am trying:
#!/usr/bin/perl
@myarray=qw/......it contain words..../;
@vowels=qw/a e i o u/;
foreach(@myarray) {
$var=$_;
for ( $p=0; $p<5 ; $p++ ) {
for ( $q=0; $q<5 ; $q++ ) {
for ( $r=0; $r<5 ; $r++ ) {
if ( $var =~ /^(.*)($vowels$p)(.*)$vowels$q(.*)$vowels$r(.*)$/ )
{ push @words_having_3_vowels, $var;
}
}
}
}
}
print "@words_having_3_vowels \n";
But not getting the expected results.
#!/usr/bin/perl
@myarray=qw/......it contain words..../;
@vowels=qw/a e i o u/;
foreach(@myarray) {
$var=$_;
for ( $p=0; $p<5 ; $p++ ) {
for ( $q=0; $q<5 ; $q++ ) {
for ( $r=0; $r<5 ; $r++ ) {
if ( $var =~ /^(.*)($vowels$p)(.*)$vowels$q(.*)$vowels$r(.*)$/ )
{ push @words_having_3_vowels, $var;
}
}
}
}
}
print "@words_having_3_vowels \n";
But not getting the expected results.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Finding vowels
by ikegami (Patriarch) on Mar 19, 2009 at 22:53 UTC | |
by AnomalousMonk (Archbishop) on Mar 20, 2009 at 03:18 UTC | |
Re: Finding vowels
by linuxer (Curate) on Mar 19, 2009 at 22:10 UTC | |
Re: Finding vowels
by ww (Archbishop) on Mar 19, 2009 at 23:29 UTC | |
Re: Finding vowels
by bichonfrise74 (Vicar) on Mar 20, 2009 at 01:25 UTC | |
by linuxer (Curate) on Mar 20, 2009 at 01:46 UTC | |
Re: Finding vowels
by Marshall (Canon) on Mar 20, 2009 at 05:33 UTC | |
Re: Finding vowels
by Utilitarian (Vicar) on Mar 20, 2009 at 10:29 UTC | |
by Anonymous Monk on Jun 12, 2011 at 08:05 UTC | |
Re: Finding vowels
by tchrist (Pilgrim) on Jun 13, 2011 at 04:44 UTC |
Back to
Seekers of Perl Wisdom