Loading Roman Numbers as Integers

use 5.010; use YAML::PP; my $yp = YAML::PP->new; $yp->schema->add_resolver( tag => "tag:yaml.org,2002:int", match => [ regex => qr/^ ([IVXLCM]+) \z/x => sub { return { I=>1, II=>2, III=>3, IV=>4, V=>5, VI=>6, VII=>7, VIII=>8, IX=>9, X=>10, }->{ $_[0] }; }], implicit => 1, # allow matching without tag ); my $data = $yp->load_string("seven: VII"); say $data->{seven}; __END__ 7
Slide 19/28 BACK UP NEXT next: ( space / -> / page up ) | previous: ( backspace / <- / page down ) | next page: ( shift + page down ) | previous page: ( shift + page up ) | index: ( arrow-up )