in reply to $! context behavior

use overload. Here is a class that returns "foo" in a string context, and retutns 1 in numeric context.

package SampleOverload; use overload '""' => \&as_string; use overload '0+' => \&as_num; sub new { bless { str => "foo", num => 1 }, shift; } sub as_string { shift()->{str}; } sub as_num { shift()->{num}; }

Interesting examples of modules using overload is y2k and Dunce::time, that magically fixes y2k or 10-digit time problem.

--
Tatsuhiko Miyagawa
miyagawa@cpan.org