Help for this page

Select Code to Download


  1. or download this
    my $fractionString = "1/2";
    my $fractionValue = ( $fractionString =~ m{^(\d+)/([1-9]\d*)} ) ? $1/$
    +2 : "undefined";
    print "$fractionString is actually $fractionValue <br>";
    
  2. or download this
    $fractionString =~ s{(\d+)/([1-9]\d*)}{$1/$2}e;