String::Fraction - convert fractions into unicode chars


String-Fraction documentation Contained in the String-Fraction distribution.

Index


Code Index:

NAME

Top

String::Fraction - convert fractions into unicode chars

SYNOPSIS

Top

  use String::Fraction;
  print String::Fraction->tweak( <<ENDOFTEXT );
    When this is run through tweak things like 1/4 and 0.25 and 6.33
    will be converted to unicode chars that represent the fractional parts
  ENDOFTEXT

DESCRIPTION

Top

This module functions identically to its superclass HTML::Fraction, but rather than converting fractions into HTML entities they are replaced by the unicode characters for those fractions.

AUTHOR

Top

Copyright Mark Fowler <mark@twoshortplanks.com> and Fotango 2005.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

BUGS

Top

None Known

SEE ALSO

Top

HTML::Fraction


String-Fraction documentation Contained in the String-Fraction distribution.

package String::Fraction;
use base qw(HTML::Fraction);

use strict;
use warnings;

our $VERSION = "0.20";

my %name2char = (
  '1/4'  => "\x{00BC}",
  '1/2'  => "\x{00BD}",
  '3/4'  => "\x{00BE}",
  '1/3'  => "\x{2153}",
  '2/3'  => "\x{2154}",
  '1/5'  => "\x{2155}",
  '2/5'  => "\x{2156}",
  '3/5'  => "\x{2157}",
  '4/5'  => "\x{2158}",
  '1/6'  => "\x{2159}",
  '5/6'  => "\x{215A}",
  '1/8'  => "\x{215B}",
  '3/8'  => "\x{215C}",
  '5/8'  => "\x{215D}",
  '7/8'  => "\x{215E}",
);

sub _name2char { shift; $name2char{shift()} }

1;