I need a command that works better than "foreach"

I have a text file that contains items such as:
bob, blue
tom, green
jill, purple

I have a script that matches the name and color inputted from a form with a line in the text file. If they match, I want to be able to print only the name without the color on the screen. I just can't figure out how to print only that part with out the whole line. I thought about using the foreach statement, but that just gives me a loop and requires everything in the line to be printed. Any ideas?
kch011099Asked:
Who is Participating?
 
jhurstConnect With a Mentor Commented:
$line=~ s/, .*//; #convert comma, space, anything to nothing
Assuming that we are using perl


0
All Courses

From novice to tech pro — start learning today.