MLUG: Re: [UUG/MLUG] perl question fo the day
Re: [UUG/MLUG] perl question fo the day
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Yea that is true .....  This will only work on an exact match though you
might want to compare them as strings with eq rather than ==

Scott 

EMAIL:PROTECTED:~
$ perl -e ' @blah = (1,2,31,4);
$bleh = 3;
if (join("",map {$bleh == $_ } @blah)) {
print "yay\n";
}
'
EMAIL:PROTECTED:~
$ perl -e ' @blah = (1,2,3,4);
$bleh = 3;
if (join("",map {$bleh == $_ } @blah)) {
print "yay\n";
}
'
yay


On Thu, 7 Oct 1999, Tymm Twillman wrote:

> $bleh in this case will also match 31, 9873, etc... anything with a 3 in
> it... (and you also need the //'s or whatever around the regexp) but
> basically this does look to be on the right track...
> 
> This should work:
> 
> ...
> if (grep(EMAIL:PROTECTED)) {
> ...
> 
> although I'm not sure what this will do with multiline variables (but if
> you're just dealing with numbers, and single-line thingies it should be
> just fine...)
> 
> -Tymm
> 
> 
> On Thu, 7 Oct 1999, Scott K. Laws wrote:
> 
> > EMAIL:PROTECTED:~
> > $ perl -e ' @blah = (1,2,3,4);
> > $bleh = 3;
> > if (grep(EMAIL:PROTECTED)) {
> > print "yay\n";
> > }
> > '
> > map works too
> > Scott
> > 
> > On Thu, 7 Oct 1999, Routier, Daniel J. wrote:
> > 
> > > Suppose I have
> > > 
> > > @blah = (1,2,3,4);
> > > $bleh = 3;
> > > 
> > > And i want to find out if $bleh is a member of @blah.
> > > as in part of a conditional statement,
> > > 
> > > if ($bleh is in @blah) {
> > >   etc
> > > }
> > > 
> > > How would you do that conditional?  I am finding no reference to it in the
> > > manual so far :(
> > > I'm assuming there is a way rather than looping through @blah searching for
> > > $bleh.
> > > 
> > > Daniel J Routier
> > > Programmer / Analyst
> > > Student Financial Aid
> > > University of Missouri
> > > 
> > 
>