Shain Edge wrote:
> I know I can use Eval, but I'm uncertain how to do it.
> 
> $x = "5+4*3-2+1";
> 
> I would like the program to give me the answer to the string math. How do I go
> about it?

use strict;
use warnings;

my $x;
eval "\$x = 5+4*3-2+1"; # you need to escape $x so it's not interpolated before 
the expr.
print "$x\n";

__END__

-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to