Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: a simple question...

by Nkuvu (Priest)
on Nov 28, 2007 at 18:07 UTC ( [id://653612]=note: print w/replies, xml ) Need Help??


in reply to Re^3: a simple question...
in thread a simple question...

Is there any way to terminate the grep upon a successful match? Not that I think it matters for only three elements, more out of curiosity (and lack of much experience with grep).

Replies are listed 'Best First'.
Re^5: a simple question...
by wind (Priest) on Nov 28, 2007 at 18:18 UTC
    Yes. Use the List::Util first function.
    use List::Util qw(first); if (my $match = first {$input{$_}} qw(info1 info2 info3)) { print "First Matched key: $match"; print "First Matched value: $input{$match}"; } else { print "none of the conditions were met\n"; }
    - Miller

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2026-02-07 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.