Gary Merrick wrote:
>
> >Homework help is a touchy subject on this list. What have you tried?
> >
> >Have you read:
> >perldoc perlop
> >perldoc perlretut
>
> Yow! Ok, I have now. I suppose I've missed something, since I haven't yet come
> up with a solution. :-\
>
> >One sticky point with and/or is that you need to break complex
> >statements into little parts and not try to put to much together at one
> >time. Use LOTS of parentheses when you are first starting out.
> >
> >When it comes to this type of thing, the more specific your question the
> >more likely you are to get a straight answer, because you have shown you
> >are not just fishing for a completed assignment....
>
> Sure thing. Here's the example we got for finding a word with no vowels:
>
> foreach (@words) {
> print "Hmm, the word '$_' doesn't contain any vowels!"
> if !/a|e|i|o|u/;
> }
>
> And here's what I've done so far:
>
> my @lines = <>;
> foreach (@lines) {
There is no good reason to read the entire file into an array first,
just use a while loop.
while ( <> ) {
> # print $_ if /a|e|i|o|u/gi; # seems to correctly find a, or e, or i...
> # print $_ if /[aeiou]/gi; # ditto
> # print $_ if /a\&\&e\&\&i\&\&o\&\&u/gi; # try a logical "and", with escapes
> # print $_ if /a&&e&&i&&o&&u/gi; # try it without the escapes
This is the closest but you need a separate match for each letter
> # print $_ if /a\&e\&i\&o\&u/gi; # try a bitwise "and", with escapes
> # print $_ if !/[bcdfghjklmnpqrstvwxyz]/gi; # try not matching consonants
> print $_ if /(a+)(e+)(i+)(o+)(u+)/gi; # "LOTS of parentheses"
By default print() prints the contents of $_ if there are no arguments
so "print if ..." does the same thing. Also none of your matches
require the /g option.
> }
>
> AAAAAAAARRRRRRRRRRGGGGGGGGGGGGHHHHHHHHH!!!!!!!!!
Fun, isn't it? :-)
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]