Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: search and return values from an array

by Anonymous Monk
on Feb 15, 2018 at 09:27 UTC ( [id://1209197]=note: print w/replies, xml ) Need Help??


in reply to search and return values from an array

@array = ("a1 b1","a2 b2","a3 b3","a5 b5","a4 b4"); print "product?\n"; chomp($prod = <>); foreach(@array){ @items = split(/ /,$_); if($items[0] eq $prod){ print $items[1]; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-03-28 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found