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 withoout 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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kim RyanIT ConsultantCommented:
($name,$color) = split(/,/,$line);
if ( $match ) { print $name);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kch011099Author Commented:
Thanks. That worked perfectly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.