in reply to incrementing strings
and turn $alias into$alias = "johnq.smith1"; $alias++;
. What you'll need to do is save the digits into a temporary variable, increment them, then append to the digitless string:"johnq.smith2"
There are, of course, other ways to achieve this, but not via directly incrementing a string.$alias = "johnq.smith1"; if ($alias =~ s/(\d+$)//) { $alias .= $1++; # $alias is now "johnq.smith2" }
Update: Ignore my response. Of course you can increment strings this way. Is it friday yet?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: incrementing strings
by ysth (Canon) on Mar 15, 2005 at 07:02 UTC |