in reply to string to expression
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: string to expression
by xiaoyafeng (Deacon) on Jan 10, 2007 at 04:51 UTC | |
by ikegami (Patriarch) on Jan 10, 2007 at 06:39 UTC |