in reply to Interesting Use of Grep

Instead of a small golf or something clever, or cluttering the routine with a few lines, I'd favor breaking it out into its own function:
if (in_list (@list, $my->{long}{to}{type}{variable}[0]) { # do something... }
That makes it clear what I mean there, rather than having a maintainer have to reverse-engineer the code. Then in that function anything goes, since it's purpose is clear and a maintainer could just replace the whole thing.

—John

Replies are listed 'Best First'.
Re: Re: Interesting Use of Grep
by AidanLee (Chaplain) on Jun 29, 2001 at 02:42 UTC

    Good point. I think i think too much in the SQL i've been working with when I wonder why i can't just say

    if( $variable in (LIST) ) { #do something... }
      Really! There is a list module somewhere. But in general why limit it to == operation? A general select (map-like but not 1:1) would be good, and it can early-out in boolean context.