Thanks for your code, I've gotta look up \Q to make sure I understand
what's happening, but it looks great. I'm still parsing your comments to
make sure I understand everything.

I'm not quite sure what you meant about side effects from my conditional
being frowned upon...how else do you use the () ? () : () conditional,
which I just consider a shortcut for if () { } else { } ? What do you mean
by "side-effects"?

I disagree (cautiously) with you about my use of 'last'. If the string
does not match $match, then the 'next' is not called, therefore the 'last'
is called and the loop exits, instead of going back and checking $string
on the next $match. Run the code with this extra print statement, and note
that on the third time through the list, the inner foreach loop exits
after the first iteration:

#!/usr/bin/perl -w

use strict;
my @strings=qw(onetwothree threeonetwo nothing);
my @matches=qw(one two three);
foreach my $string (@strings) {
    my $success=1;
    foreach my $match (@matches) {
        print "looping\n";
        ($string=~/$match/) ? (next) : ($success=0);
        last;
    }
    ($success) ? (print "$string matches.\n") : (print "$string does not
match.\n");
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to