How do I multiply negative number with Perl?

I need to multiply a variable that contains a negative value by negative one.  Such as $test=(-1*$amount) where amount is negative.  I can't even get print "Test (-1*$amount)"; to work.  This prints: -1*-300.  
Shearer-ServicesAsked:
Who is Participating?
 
TintinConnect With a Mentor Commented:

Either do

$test = -1 * $amount;
print "$test\n";

or

print -1 * $amount , "\n':

0
 
ozoConnect With a Mentor Commented:
 $test=(-1*$amount) ;
should work.
so would
  $test = -$amount;

  print "Test (-1*$amount)";
will just print the "Test (-1*" litterally
perhaps you meant
  print "Test", -1*$amount,"\n";
0
 
Shearer-ServicesAuthor Commented:
Despite my typo, you both helped answer the question.  Thanks
0
All Courses

From novice to tech pro — start learning today.