> I actually rather like MikeL's suggestion for the unary ops; clear, > concise, and highly readable. And look: > > my str $s = sprintf("%x", $i); # 30 characters > my str $s = hex $i; # 19 characters > my $s = ~hex $i; # 16 characters
I think these are good, but I really think that Larry's idea of an "as" function is the best. Not only does it provide a decent syntax my str $s = $i.as("%x"); it also has the ability to be overloaded for various user defined types.