View Single Post
  #1 (permalink)  
Old 01-07-04, 11:56 AM
gmadhukarreddy gmadhukarreddy is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
suggest a regular expression

i have a line like ....

123..345,456..567,678..789

and i have to substitute each number (like 123) by adding something to it (all at one go - the whole line)

so if i have to add 20 to each,

the regular expression should substitute 123 by 143 (i.e.123+20 )
345 by 365
456 by 476 and so on

so how can I write the regular expression ????

can I write something like

$a =~ s/\d+/eval($&+20)/g;

where i need to get the evaluated value to be substituted. but it is not evaluating...
Reply With Quote