in reply to Re: Assign result of map to scalar variable
in thread Assign result of map to scalar variable

... if the regex fails on the first value, then the scalar is undef ...

I agree that if you want processing to stop, already, after the first match, a for-loop is the way to go.

However, in the code you're using in your example map blocks, the value assigned to a scalar in list-context in the event of match failure would be the empty string, not undef.

(I should mention that even though the OP is a bit unclear on this point, I assume that the  @GET_STRING array may contain any number of matching or non-matching strings in any order.)

Replies are listed 'Best First'.
Re^3: Assign result of map to scalar variable
by Laurent_R (Canon) on Jul 19, 2013 at 09:56 UTC

    Yes, you are right, AnomalousMonk, it is an empty string, not undef. I made the correction.