If you're seeking words which contain three different vowels (a possibility which is neither ruled-in nor ruled-out by your initial post), this is one of many ways to do so:
#!/usr/bin/perl use strict; use warnings; # cf pl_test/751890.pl my @myarray=qw/two three threee fouuuuur five septigesimal sodium hexa +flouride/; my @vowels=qw/a e i o u/; my @words_having_3_vowels; for my $var(@myarray) { my $seen; for my $vowel(@vowels) { if ($var =~ m/$vowel/) { $seen++; if ($seen == 3) { push @words_having_3_vowels, $var; next; } } } } for my $words(@words_having_3_vowels) { print "$words \n"; } =head execution output: pl_test/751890_a.pl septigesimal sodium hexaflouride =cut

Now, echoing responses above, please read about <code>...</code> (or <c>...</c> tags in Writeup Formatting Tips or Markup in the Monastery so that your code is readable (what you did is, but more complex code, or that using characters like [ would NOT be readable without code tags.

And read also How do I post a question effectively? because "But not getting the expected results." is not a description of the problem which clarifies your problem. Also, as noted above, your description of what you're trying to achieve is ambiguous./p>

Finally, the original code, cleaned up to use strict; and use warnings;; with variables declared (albeit, not constrained as to scope with appropriate indentation (well, one legible version of 'appropriate' indentation, of which there are many);

#!/usr/bin/perl use strict; use warnings; my @myarray=qw/two three threee fouuuuur five septigesimal/; my @vowels=qw/a e i o u/; my @words_having_3_vowels; foreach(@myarray) { my $var=$_; for ( my $p=0; $p<5 ; $p++ ) { for ( my $q=0; $q<5 ; $q++ ) { for ( my $r=0; $r<5 ; $r++ ) { if ( $var =~ /^(.*)($vowels[$p])(.*)$vowels[$q](.*)$vo +wels[$r](.*)$/ ) { push @words_having_3_vowels, $var; } } } } } for my $result(@words_having_3_vowels) { print "|$result|\n"; } =head execution output: |threee| |fouuuuur| |fouuuuur| |septigesimal| |septigesimal| |septigesimal| |septigesimal| |septigesimal| |septigesimal| |septigesimal| |septigesimal| =cut

This is unnecessarily hard on you and the future reader and could be avoided by <insert> either of</insert> the technique ikegami cites; it's also far more work to type (and track) than linuxer's solution. Note, however, that his output is a per-word vowel count; not the words with 3 or more vowels, and also that lines 20-22 in my "cleaned up" version change your print command (line 16 by my count) to a print-in-a-loop that prints a word (wrong: each time its vowel-count exceeds two) (correction: one or more times for reasons I'm too lazy to explore and elucidate).

Update Inserted the italicized clarification re ikegami's suggestions.
update 2 Original statement re output, now stricken, is incorrect.


In reply to Re: Finding vowels by ww
in thread Finding vowels by paragkalra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.