R
robin.corcoran
Hello, I have to add to a number in a s/r. My input looks like
Page 1
Page 2
Page 3
I want
Page 6
Page 7
Page 8
Using /e I'm able to add to a number
$string=~s/([0-9]+)/$1+1/e
My problem comes from the fact that I don't want to globally replace
every number. I just want to replace those with "Page #". However, the
/e option is looking for a method when I add text to the replace
string.
$string=~s/Page ([0-9]+)/Page $1+1/e; yields
"Can't call method page without a package or object.
I tried using \Q and \E in my replace string and that doesn't help. I
even tried using \x.. to output "Page" but that doesn't work either.
Is what I'm trying even possible, and if so can someone nudge me in the
right direction?
Thanks,
Robin
Page 1
Page 2
Page 3
I want
Page 6
Page 7
Page 8
Using /e I'm able to add to a number
$string=~s/([0-9]+)/$1+1/e
My problem comes from the fact that I don't want to globally replace
every number. I just want to replace those with "Page #". However, the
/e option is looking for a method when I add text to the replace
string.
$string=~s/Page ([0-9]+)/Page $1+1/e; yields
"Can't call method page without a package or object.
I tried using \Q and \E in my replace string and that doesn't help. I
even tried using \x.. to output "Page" but that doesn't work either.
Is what I'm trying even possible, and if so can someone nudge me in the
right direction?
Thanks,
Robin