Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Is for the wrong choice here?

by Masem (Monsignor)
on Jan 18, 2002 at 21:57 UTC ( #139885=note: print w/ replies, xml ) Need Help??


in reply to Is 'for' the wrong choice here?

grep is better here:
if ( grep { /($author)/i } @admin_users ) { print "$blah\n"; } else { print "$uber_blah\n"; }

Update -- Should be matching on $author, not $admin_user (the value from the loop in question).

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: Is for the wrong choice here?
by grep (Monsignor) on Jan 18, 2002 at 22:15 UTC
    This should work a little better
    #!/usr/bin/perl -w use strict; my $author = 'grep'; my @admin_users = qw/test that grep out/; if ( grep { /^$author$/i } @admin_users ) { print "blah\n"; } else { print "uber_blah\n"; }


    grep
    grep> cd pub
    grep> more beer
Re: Re: Is for the wrong choice here?
by jerrygarciuh (Curate) on Jan 18, 2002 at 22:04 UTC
    Well, that works better than what I had except that it apparently tests true every time. Every iteration is printing $blah even when $author is not a match. Advice?
    TIA
    jg
    _____________________________________________________
    If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ
      This code gets the same results:
      if ( grep { /($admin_user)/i } $author ) { print "$blah "; } else { print "$uber_blah"; }

      TIA
      jg
      _____________________________________________________
      If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://139885]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2016-06-29 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (365 votes). Check out past polls.