>>>>> "perl" == perl <[EMAIL PROTECTED]> writes:
perl> Can someone show me how to make this compute? perl> my $a=2; perl> my $b=3; perl> my $oper="+"; perl> my $c = $a $oper $b; perl> where $c would have a value of 5. A lot faster and safer than the "eval" solution: my %ops = ( "+" => sub { $_[0] + $_[1] }, "-" => sub { $_[0] - $_[1] }, ..., }; my $c = $ops{$oper}->($a, $b); -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]