in reply to Execute a string which has math operation
Use eval:
#! perl use strict; use warnings; my ($a, $b, $c) = (4, 2, '-'); my $op = "$a $c $b"; print "$op = ", eval $op, "\n";
Output:
14:39 >perl 823_SoPW.pl 4 - 2 = 2 14:39 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Execute a string which has math operation
by bulk88 (Priest) on Jan 05, 2014 at 07:23 UTC | |
by Preceptor (Deacon) on Jan 05, 2014 at 10:22 UTC | |
|
Re^2: Execute a string which has math operation
by irah (Pilgrim) on Jan 05, 2014 at 04:44 UTC |