From: "Steven Arbitman" <[EMAIL PROTECTED]>

> I have a problem which is simple to state:
> 
> Find all prices in a file, multiply them by 2.5, and print out the
> file with the new prices.
> 
> It seemed like a good use for substitution at first.
> 
> The following successfully finds the prices and saves them in memory:
> 
> /\$([0-9.]+)/
> 
> (a dollar sign followed by one or more digits and periods).
> 
> However, attempting to substitute:
> 
> s/\$([0-9.]+)/\$($1*2.5)/

You want 

        s/\$([0-9.]+)/'$' . ($1 * 2.5)/ge;

The /g makes sure you change all prices, not just the first, the /e 
instructs Perl to treat the replacement not as a string, but as a 
code block.

Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
                                        --- me


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to