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.
Back to
Seekers of Perl Wisdom