in reply to Scope and Context
From the description of eval in perlfunc,
... the value returned is the value of the last expression evaluated inside the mini-program; a return statement may be also used, just as with subroutines. The expression providing the return value is evaluated in void, scalar, or list context, depending on the context of the eval itself.So your map is executed in a list context, and becomes the return value of the eval (assuming no exception was thrown). Works for me, though explicitly assigning to a temporary array might make the core more readable. Then again, if you're concerned about space before readability, drop in a comment to remind the reader how eval works.
Your code fragment doesn't show you're checking to see if eval has caught an exception, which it might if there was a bogus regexp in the file.
|
---|