in reply to returning scalar context from map or grep

By assigning the result of a map or grep to a scalar, you already put the map or grep into scalar context. However, that doesn't solve your problem. Your problem isn't how to place map or grep into scalar context, your problem is getting the first result of the map or grep. To get this, you must evaluate the map or grep in list context, and take the first result from that. There are various ways of doing that, I prefer:
my ($first) = map {whatever} @array;

Abigail