#!/usr/bin/perl -i.bak

use English;

## get input
undef $INPUT_RECORD_SEPARATOR;
$file = <>;

## transform it

$numberRE = '-?\d+(?:\.\d+)?';
$file =~ s/(^|\W)($numberRE(?:^.)?)\/($numberRE(?:\^.)?)(\W|$)/$1\\frac{$2}{$3}$4/;

# print output
print $file; 





