[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I multiply negative number with Perl?

Posted on 2003-11-23
3
Medium Priority
?
1,039 Views
Last Modified: 2013-12-25
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.  
0
Comment
Question by:Shearer-Services
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 100 total points
ID: 9807635

Either do

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

or

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

0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 100 total points
ID: 9808762
 $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
 

Author Comment

by:Shearer-Services
ID: 9810319
Despite my typo, you both helped answer the question.  Thanks
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question