#!/usr/local/bin/perl # # Extract those words from switchboard.lexicon that have at least 3 vowels # $file = "switchboard.lexicon"; open(word_file,$file); @lines_in_file = ; close(word_file); print "Words from switchboard.lexicon that have at least 3 vowels\n"; $i=0; foreach $line_in_file (@lines_in_file) { if ($i < 10) { #First 10 words in the lexicon do not seem to be normal words ++$i; next; } $line_in_file =~ /^(\S+)\s/; #Extract the initial letters till 1st $word = $1; #whitespace as the word from lexicon if ($word =~ /^.*[AEIOU]+.*[AEIOU]+.*[AEIOU]+.*$/) { #check for at least 3 vowels printf "$word\n"; } }