calculation in string

D

Daniel

I've a dynamic variable
$var_tmp = "/18";
where the "/18" can also be "/18+100"
I also got a variable
$var_prize = 2000
now the thing is I have to get this
$var_total = 2000/18+100;

anybody knows how this works ?!?
 
P

Purl Gurl

Daniel said:
I've a dynamic variable
$var_tmp = "/18";
where the "/18" can also be "/18+100"
I also got a variable
$var_prize = 2000
now the thing is I have to get this
$var_total = 2000/18+100;
anybody knows how this works ?!?


Yours does not work.

2000 / 18 + 100 = 211.111111111111111111111111111111

2000 / (18 + 100) = 16.9491525423728813559322033898305


Give this some thought.


Purl Gurl
 
E

Eric J. Roode

I've a dynamic variable
$var_tmp = "/18";
where the "/18" can also be "/18+100"
I also got a variable
$var_prize = 2000
now the thing is I have to get this
$var_total = 2000/18+100;

anybody knows how this works ?!?

$var_total = $var_prize . $var_tmp; ??
 
T

Trent Curry

Daniel said:
I've a dynamic variable
$var_tmp = "/18";
where the "/18" can also be "/18+100"
I also got a variable
$var_prize = 2000
now the thing is I have to get this
$var_total = 2000/18+100;

anybody knows how this works ?!?

$var_total = eval($var_tmp);
will do what you want.

Also, alt.comp.lang.perl & comp.lang.pelr are very rare if not virtually
extinct news groups. I don't think too many people get them. Though there
seems to be SOME activity in those two said groups...
 
T

Trent Curry

Daniel said:
I've a dynamic variable
$var_tmp = "/18";
where the "/18" can also be "/18+100"
I also got a variable
$var_prize = 2000
now the thing is I have to get this
$var_total = 2000/18+100;

anybody knows how this works ?!?

$var_total = eval($var_tmp);
will do what you want.

Also, alt.comp.lang.perl & comp.lang.perl are very rare if not virtually
extinct news groups. I don't think too many people get them. Though there
seems to be SOME activity in those two said groups...

Or is alt.comp.lang.perl just a lesser known group?
 
A

Anno Siegel

Trent Curry said:
$var_total = eval($var_tmp);
will do what you want.

Also, alt.comp.lang.perl & comp.lang.perl are very rare if not virtually
extinct news groups. I don't think too many people get them. Though there
seems to be SOME activity in those two said groups...

Or is alt.comp.lang.perl just a lesser known group?

alt.comp.lang.perl is a legit alternative to the mainstream Perl groups.
comp.lang.perl has been decommissioned many years ago -- it *shouldn't*
exist anywhere, but a sizeable minority of news server still carry it.

Anno
 
T

Trent Curry

--
Stan
Anno Siegel said:
alt.comp.lang.perl is a legit alternative to the mainstream Perl groups.
comp.lang.perl has been decommissioned many years ago -- it *shouldn't*
exist anywhere, but a sizeable minority of news server still carry it.

Unfortunately, my server carries both :(
Thank you for the info though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top