in reply to a natural way of expressing things

Have a look at any in List::MoreUtils:

if ( any { $expression eq $_ } $val1, $val2, $val3 ) { #blah, blah, blah }

Replies are listed 'Best First'.
Re^2: a natural way of expressing things
by johngg (Canon) on Jul 08, 2007 at 16:55 UTC
    Are there are any advantages in using any from List::MoreUtils over using grep?

    if ( grep { $expression eq $_ } $val1, $val2, $val3 ) { ... }

    Just wondering as I'm not really familiar with that module.

    Cheers,

    JohnGG

        scalar context list context
      grep looks at the entire list and returns the number of times the expression was true returns the list of things that matched
      any only looks at as much of the list as it needs to. ie it will stop after the first true condition.

      I've never tried a table on PM before. It looks OK(ish) here. Please /msg me if it's a disaster on other platforms.

      update: I was using <table border-width=1> instead of border=1. Thanks to holli for noticing.