SPUG: Interesting bug using 'map'

Michael R. Wolf MichaelRWolf at att.net
Fri Apr 10 11:44:26 PDT 2009


On Apr 9, 2009, at 8:52 PM, seasprocket at gmail.com wrote:

> The bug arises bc fropper and glopper are not guaranteed to have  
> return values for fee/fi/fo, and bc map evaluates BLOCK in LIST  
> context. So if fee or fi is undefined, you get an empty list which  
> collapses in the final result. Then fi or fo can get assigned to the  
> wrong variable.

You are describing the documented behavior, not a bug.

See 'perldoc -f map'

If you don't like the interaction between the existing functions,  
either rewrite them, or create wrapper functions that return the  
scalar value that you want to represent 'failure'.  That value can be  
empty string, zero, even undef.  From the limited description of your  
requirements, it sounds like 'return undef' would work for your  
requirements.

-- 
Michael R. Wolf
     All mammals learn by playing!
         MichaelRWolf at att.net






More information about the spug-list mailing list