in reply to Comparing Scalars and Arrays
If it smells like grep and looks like grep, then it must be grep :-)
I see that you in your question has assigned an anonymous array to @array, if that really is the case, then you have to do some more work:if( grep { $scalar == $_ } @array ) { print "$scalar is member of @array\n"; } else { print "$scalar is not member of @array\n"; }
Autark.$scalar = 3; @array = ([1, 2], [3, 4, 5], [6, 7, 8 ,9]); if( grep { $scalar == $_ } map { @$_ } @array ) { print "Yes\n" } else { print "No\n" }
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: Comparing Scalars and Arrays
by cwest (Friar) on Jul 19, 2000 at 21:36 UTC |
In Section
Seekers of Perl Wisdom