abualiga has asked for the wisdom of the Perl Monks concerning the following question:
Hi there, I'm trying to understand interpolation of operators within strings. Specifically, can mathematical operators be interpolated within strings and evaluated as operators. Below is some example code to make my question clear. Many thanks!
my @ops = ( '-', '+', '*', '/' ); for( @ops ) { my $a = "2 $_ 2"; say $a; }
Is it possible iterate over these operations and perform calculations?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: interpolating operators within strings
by NetWallah (Canon) on Apr 14, 2013 at 01:34 UTC | |
Re: interpolating operators within strings
by kcott (Archbishop) on Apr 14, 2013 at 02:16 UTC | |
by educated_foo (Vicar) on Apr 14, 2013 at 03:51 UTC | |
by RichardK (Parson) on Apr 14, 2013 at 12:54 UTC | |
by abualiga (Scribe) on Apr 14, 2013 at 03:29 UTC | |
by kcott (Archbishop) on Apr 14, 2013 at 04:01 UTC | |
by TJPride (Pilgrim) on Apr 14, 2013 at 13:34 UTC |
Back to
Seekers of Perl Wisdom