Scott Ulmen wrote:
There must be a better (read shorter) way to do what I did.
foreach $singleline (@lines) {
my @stuff = $singleline =~ /\b\w*[^aeiou\s]{4}\w*\b/ig;
@stuff and print "matched: ", join( ',', @stuff ), "\n";
}
The regular expression:
/\b\w*[^aeiou\s]{4}\w*\b/ig
1. \b means "word boundry"
3. \w* means zero or more word characters
4. \s means white-space
5. the switch 'g' finds all occurences on the line
6. in array context (@stuff) each match is an element
And since you want "shorter", here's a one-liner...
#!/usr/bin/perl -w
map { print "matched: $_\n" } m/\b\w*[^aeiou\s]{4}\w*\b/ig for <DATA>;
__DATA__
This is a test file.
There are only two words that meet the match.
Those words are thoughts and yardstick.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>