[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] testing



The solution may be rethinking the algorithm, which would be difficult
without knowing what the algorithm is.  From the perspective of matching
multiple values simultaneously, you could:

Use an array:
    @array = qw($a $b $c $d);
    if( grep( /^$value$/, @array ) )...

Or string/regex:
    $concat = "$a $b $c $d";
    if( $concat =~ /(^| )$value( |$)/ )...

Hope this helps.

-K

"A foolish consistency is the hobgoblin of little minds"

> From: Nicholas.G.Thornton@directory.reed.edu (Nicholas G. Thornton)
> Date: 14 Dec 1999 15:54:40 PST
> To: macperl@macperl.org
> Subject: [MacPerl] testing
> 
> in the test part of an if statement is there a way to simplify...
> if ($value == $a or $value == $b or  $value == $c or $value == $d or ...)
> ....into...
> if ($value == ($a or $b or $c or $d or...))
> ....or something similar? I can't seem to find it in the Camel book.
> 
> le meas,
> --Nick
> 
> # ===== Want to unsubscribe from this list?
> # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org
> 


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org