Solved

Perl multiplication

Posted on 1999-01-04
8
699 Views
Last Modified: 2012-05-04
Hi,
I'm working now with new shopping cart script.
As you know probably we have new EURO currency
since January 1st in Europe.
This currency has fixed & definitive rate to all other
european currencies.
 
My total amount in French Francs in my shopping cart is
displayed with this variable:
 
print "$ITEM{'price'}"
 
And fixed parity of FRF to new EURO is  0.152449
 
I tried to get the equivalency of total amount in EURO
this way :
 
print "($ITEM{'price'} ** 0.152449)"
 
but the script doesn't make a multiplication at all and displays
simply "item price in FRF taken from database" ** 0.152449  on the screen.

Then I tried to create variable $euro in shop.cfg
which was stipulated:

$euro = $ITEM{'price'}*0.152449

and then in the script:  print"$euro"

but this solution prints "0" (zero) on the screen instead
total in euros.
 
I know that this is really Perl school problem but maybe you
can avoid me to search in all Perl books;I didn't find really
simple solution in Perl tutorial included with Perl.
 
Thanks in advance and
Happy New Year for all.
 
Adam
0
Comment
Question by:adamgortych
  • 4
  • 3
8 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1207309
Perl Question
   Title: "Perl multiplication"

   From: adamgortych
                                       Date: Monday, January 04 1999 - 03:32PM PST
   Status: Waiting for answer
   Points: 50 Points (Easy)


   Hi,
   I'm working now with new shopping cart script.
   As you know probably we have new EURO currency
   since January 1st in Europe.
   This currency has fixed & definitive rate to all other
   european currencies.
     
   My total amount in French Francs in my shopping cart is
   displayed with this variable:
What is in $ITEM{price}? if it is the string 'price in FRF' that will be treated as 0 when used as a number
0
 

Author Comment

by:adamgortych
ID: 1207310
Edited text of question
0
 

Author Comment

by:adamgortych
ID: 1207311
Edited text of question
0
 

Author Comment

by:adamgortych
ID: 1207312
$ITEM{price} is the price in FRF taken from flat text database so it's different
for each item but always in FRF
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 84

Expert Comment

by:ozo
ID: 1207313
the string "item price in FRF taken from database" does not look like a number to Perl
if you want $ITEM{'price'}*0.152449 to be other than 0, y0u must place a number in $ITEM{'price'}
(by the way ** is exponentiation, not multiplication)
0
 

Author Comment

by:adamgortych
ID: 1207314
when I wrote "item price in FRF taken from database" it was just to say that
the multiplication is not done by the script and full display on the screen is:
price of item taken from database,then signs ** and 0.152449,so nothing
is done.
I have one fixed value which is euro rate and another value is french francs
price taken from database which is different for each item.
I would like simply get the prices in euros displayed on the screen near FRF price
for each item,always with the same exchange rate which will never change more.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1207315
print "($ITEM{'price'} ** 0.152449) = ",$ITEM{'price'} * 0.152449;

$euro = $ITEM{'price'}*0.152449; print $euro; #should work too
0
 
LVL 1

Accepted Solution

by:
Cov earned 50 total points
ID: 1207316
$euro = "23";
$item{'test'} = $euro * 0.152449;
print $item{'test'};  

works fine... check out the fact your are doing multiplication, not exponentiation.


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now