Re: one more regex match elements in an array question

2002-12-20 Thread Paul Johnson
On Fri, Dec 20, 2002 at 09:13:41PM -, Rob Dixon wrote: > Please explain about that useful-looking command-line syntax. It looks to be > equivalent to > > use O qw(Deparse -p); Yep. that's it. > but I've never heard of module 'O'. O.pm is the interface to the B compiler modules. In thi

Re: one more regex match elements in an array question

2002-12-20 Thread Rob Dixon
OK first round to you! Please explain about that useful-looking command-line syntax. It looks to be equivalent to use O qw(Deparse -p); but I've never heard of module 'O'. Is it anything to do with the Powerpuff Girls' Chemical X? Puzzled, /R "Paul Johnson" <[EMAIL PROTECTED]> wrote in me

Re: one more regex match elements in an array question

2002-12-20 Thread Paul Johnson
On Fri, Dec 20, 2002 at 12:11:42PM -, Rob Dixon wrote: > We make a good team Paul ;-} :-) But you do actually need the parens in the index call, otherwise the precedence is wrong: $ perl -MO=Deparse,-p -e '@match = grep { index $_, $string >= 0 and $_ ne $string } @array;' (@match = grep({

Re: one more regex match elements in an array question

2002-12-20 Thread Rob Dixon
We make a good team Paul ;-} "Paul Johnson" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > I don't know about better, but why not code it exactly as you describe > it? > > @match = grep { index($_, $string) >= 0 and $_ ne $string } @array; > > This has the

Re: one more regex match elements in an array question

2002-12-20 Thread Paul Johnson
On Fri, Dec 20, 2002 at 05:00:04PM +0530, Ramprasad wrote: > hello all > > Assume the foll > > $string='mail.com'; > @array=qw(mail.com one.mail.com two.mail.com mail.com/one mail1.com); > > @match = grep{..}@array; > > I want to match all that *contain* $string but is not equal to $string >

Re: one more regex match elements in an array question

2002-12-20 Thread Rob Dixon
Ramprasad Yours isn't a general solution anyway, as any periods in your string will match any character in a list entry. I would use the plainer: @match = grep { index $_, $string >= 0 and $_ ne $string } @array; Cheers, /R "Ramprasad" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED