in reply to Type::Coercion on the fly

Try it like this:

my $more_magnetude = Type::Coercion->new( name => 'MoreMagnitude', type_constraint => Num, type_coercion_map => [ Str, sub { $lookup->{$_}* 11 } ], );

See the documentation of the constructor and attributes of Type::Coercion.

(If it makes you feel any better, it took me a several minutes to spot what you were going wrong.)

Replies are listed 'Best First'.
Re^2: Type::Coercion on the fly
by jandrew (Chaplain) on Jul 08, 2014 at 16:08 UTC

    tobyink++

    That was both fast and helpful! Thanks for the solution and the pointer to the documentation.

    Update: I'm looking forward to the book!