[EMAIL PROTECTED] wrote:
Here's a string in my file,

#define MY2D_STRING            "4.0.1.999.9"

of which I'm trying to increment the last digit; let's say with 1,

such that the output is 4.0.1.999.10

I've tried _various_ combinations, here's just one of them.
(This works partially, but not always).

perl -i -pe 'if (/(MY2D_STRING\b.*)(.\d+)"/){$a=$2;s/$a/$a+1/ge}'
$filename

------------
Also, another one (though I can figure this out with help with just
the first one)

MY3D_STRING(test, 4.0.1.999.9)

$ echo '
#define MY2D_STRING            "4.0.1.999.9"

MY3D_STRING(test, 4.0.1.999.9)

' | perl -pe'/MY\dD_STRING/ && s/(\d+)(\D*)$/ $1 + 1 . $2 /e'

#define MY2D_STRING            "4.0.1.999.10"

MY3D_STRING(test, 4.0.1.999.10)




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to