Maybe you just want eval? Consider:
use strict; use warnings; my @operators = qw(+ - * /); my $expression = (int rand(100)) . $operators[int rand(4)] . (int rand +(100)); my $answer = eval $expression; print "$expression = $answer";
Prints (for example):
78+63 = 141
In reply to Re: string to expression
by GrandFather
in thread string to expression
by xiaoyafeng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |