Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incrementing a string??

Status
Not open for further replies.

Zippeh

Programmer
Sep 24, 2002
56
GB
Hi there :)

I have a reference that I read from a file that I want to increment. The reference is of the form:

xx0001 where xx are letters and 0001 is a number between 0001 and 9999. What I want is to increment this number. I'm not concerned about what happens after 9999 at this moment in time. How can I go about incrementing this number?

I have tried the following:

Code:
    if (/($enwCyfeirnod=)(\w{2})(\d{4})/) {
      my $rhifCyfeirnod = $3;
      print $rhifCyfeirnod++;
    }

This pulls out the correct values the brackets, but I'm unable to simply increment $3.

Many thanks :)
 
Ignore this! Just realised the the increment is happening after I print it out! Doah!
 
Are you coding in Welsh? If so good stuff ;-)
--Paul

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Am indeed mate!

All variable names, comments, programme names, filehandles! Anything that needs naming is in welsh :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top