#!/usr/bin/perl # Perl 5 use strict; use warnings; while (my $txt = ) { chomp($txt); next unless my ($term) = ($txt =~ m/.+=(.+)$/); $term = lc($term); # SQRT -> sqrt $term =~ s/pot\((.*?)\)/$1**2/g; # POT(x) -> x**2 my $result = eval($term); print "$txt=$result\n"; } __DATA__ ABC=1+1 Z=SQRT(POT(320)+POT(200))