Alex Cheung Tin Ka wrote: > > From: "John W. Krahn" <[EMAIL PROTECTED]> > > > Alex Cheung Tin Ka wrote: > > > > > > I have a problem about the list value. > > > I have got a scalar say $a='a' and a list say @b = ('a', 'b','c'); > > > how can I check whether $a is one of the value in @b. Is there any > > > easy way to do it and I got lost in perl.com's piles of documentation. > > > > if ( grep $a eq $_, @b ) { ... } > > > > use Quantum::Superpositions; > > if ( $a eq any( @b ) { ... } > > what is the difference with this? > grep(/$a/, @b); > & > grep $a eq $_, @b;
$ perl -e' $a = q/d/; @b = qw/a b c d e f zzdzz g/; grep /$a/ && print( "regex: $_\n" ), @b; grep $a eq $_ && print( "equate: $_\n" ), @b; ' regex: d regex: zzdzz equate: d John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]