in reply to grep for a name

You don't mention what's not working up to your expectations, but my guess is that $goal being set to Type: is not what you want. You're unnecessarily capturing a constant string. You should either not capture it: if (m/^Type:\s*(\w+)/) { $goal = $1 }or use non-capturing parens: if (m/^(?:Type:)\s*(\w+)/) { $goal = $1 }or keep the pattern the way it is and pull out the second pair of parens: if (m/^(Type:)\s*(\w+)/) { $goal = $2 }Many more details at perlop (look for "Quotes and quote-like operators") and perlre.

This is all guesswork on my part about what the problem is. Hope I guessed right!