Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: string functions

by valavanp (Curate)
on Oct 25, 2006 at 09:23 UTC ( #580517=note: print w/replies, xml ) Need Help??

in reply to Re: string functions
in thread string functions

The result is the product of 2A2B2C. You have summed up like this (2A)*(50/100)+(2B) * (55/100)+(2C) * (60/100). But i need the product of the result. In the morning when i am in the chatter box tye suggested me to go for if loop, that's why i went through if else.

Replies are listed 'Best First'.
Re^3: string functions
by Corion (Pope) on Oct 25, 2006 at 09:31 UTC

    If you need the product, why are you expanding your string at all? You should then be able to calculate your product by simply multiplying the letters by their factors in front. But if I interpret what you say that way, I still don't get your result:

    perl -le "print 2*1.5*(50/100)*2*2.5*(55/100)*2*3.5*(60/100)" 17.325

    Please explain what calculation you want to perform.

    The structure of if..elsif is a very cumbersome way to approach your problem, so I doubt that tye recommended it as a solution for this specific problem.

      basically i have A,B,C,D,E,F,G,H,J values in an array. The factor's letter should depend on that array. The solution which i want for the string: $a="4ABC" or "3C" or "2A2B2C" or "ABC" .. The result of $a should be (A * A * A * A) * (50/100) * B *(55/100) * C * (60/100). This only what i want. The solution given by holli calculates for only certain values. when i tested with some other values it directly prints the string.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://580517]
[marto]: Morning, looks like our client office will be closed due to bad weather

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2018-01-17 07:49 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (196 votes). Check out past polls.