At 12:28 PM 8/16/01 -0400, Yacketta, Ronald wrote:
>Peter/All;
>
>Is this what you had in mind, offered as a suggestion?
Heading in the right direction, but some syntactical derailments along the way.
>if ($test = /($regex)/o) {
Nope, you need to put $test in list context to save the result.
> SWITCH: for ($test){
> if ( $test =~ /Communication/ ) {
The $test =~ is redundant
> $results{$test}++ if ( $_ =~ /$test/ && $_ =~
As is the $_ =~
>/failure/);
> last SWITCH;
> }
>....
>....
That's one way. To reiterate: make one regex which matches all the
different things you want to match. Save whatever matched. Then you can
handle the things that are always done if you got a match on any thing,
followed by the things that have to be done for specific cases in some
switching type of structure. Try and minimize these specific cases by
finding ways of folding them into the generic code.
> }
>}
>
>Regards,
>Ron
>
>
> > -----Original Message-----
> > From: Peter Scott [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, August 14, 2001 16:13
> > To: Yacketta, Ronald; Beginners (E-mail)
> > Subject: RE: Code for review
> >
> >
> > At 01:38 PM 8/14/01 -0400, Yacketta, Ronald wrote:
> >
> > > > $regex = 'join ('|', keys %lookFor);
> > > > if (/($regex)/o) {
> > > > # Now switch on $1 for your specific sub-tests like
> > /Factory/ etc
> > > > }
> > > >
> > >
> > >could you kindly elaborate some on this part?
> > >I thought one could only "switch" on numeric values?
> > >
> > >switch {
> > >case 1:
> > >case 2:
> > >case 3:
> > >default:
> > >}
> >
> > Ooh, that's some other kind of language. No, I meant the
> > Perl kind of
> > switch, as in
> >
> > http://www.cpan.org/doc/FMTEYEWTK/switch_statements
> >
> > Which just means testing $1 against various things the way
> > you were doing
> > it. Actually, it would be best to save $1 first, so
> >
> > if (my ($match) = /($regex)/o) {
> > # test $match
> >
> > --
> > Peter Scott
> > Pacific Systems Design Technologies
> > http://www.perldebugged.com
> >
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]