in reply to Re^2: Increment a string with letters and numbers
in thread Increment a string with letters and numbers
I have the same question but how is this done if there are for example EVO:001, EV0:002, EVO:003 in a file and I want each one incremented.. I just want to supply EVO: then have it increment the number part. The closest I have gotten is this but it injects a one instead of incrementing the variable
#!perl=C:\bin\perl use warnings; use strict; use Tie::File; tie my @data, 'Tie::File', 'myfile.txt' or die $!; sub inc { my ($num) = @_; ++$num } s/(MyString\d+)/$1 . (inc($2))/eg for @data; untie @data;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Increment a string with letters and numbers
by Athanasius (Archbishop) on May 21, 2013 at 03:14 UTC | |
by emptyshell (Initiate) on May 21, 2013 at 04:55 UTC |