Hi,

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)/

results in the literal characters "(formerprice*2.5)" being inserted rather
than the arithmetic operation being performed.

Also, there are cases where there are two prices on the same input line.  I
was assuming I would use the /g modifier to handle them.

Is this approach going to work?  Or is there a better way?  (The prices are
not located in the same fixed position, and each input line may have zero,
one, or two prices).

The goal is to quickly program a one-time job.

Thanks,
Steve


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

Reply via email to