#! /usr/bin/perl use strict; use warnings; print < "; my $line = <>; if( ! $line ) { last; } chomp $line; chomp $line; if( $line ne "" ) { $line =~ s/([0-9]*(\.[0-9]*)?)mm/($1\/0.000254)/g; $line =~ s/([0-9]*(\.[0-9]*)?)mil/($1\/0.01)/g; $line =~ s/([0-9]*(\.[0-9]*)?)pcb/($1\/1.0)/g; $line =~ s/[^0-9.()*\/+-]//g; # this is important for letting through only arithmetic expressions my $result = eval( $line ); if( defined $result ) { printf( "%f\n%fmm\n%fmil\n%fpcb\n", $result, $result * 0.000254, $result * 0.01, $result * 1.0 ); } else { print( "error\n" ); } } # if( $line ne "" ) } # while( 1 )