We don't bite newbies here... much | |
PerlMonks |
increment id numby Anonymous Monk |
on Oct 16, 2003 at 14:37 UTC ( [id://299760]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hiya Monks! I having a small problem here and i dunno enough about regular expressions to to solve it. Ive got this file with lines similar to this inside:
when i add a new record i need to add a new id number that is in sequence with the last record entered. So for instance if the last id was 'I000199', the added record would have id 'I000200'. There is a small problem though, that there are some id numbers randomly missing, so they arent relational to the line num. I basically need to find the last entry with an id num, remove the 'I', look at the num and increase it by 1 but still keeping it 6 digits long, and attach it to the new entry with an 'I' prefixed in front. I am using the split function to make each line an array. I was think of maybe using the split function again on the first element, to remove the 'I' (using substr to get the first letter)? That would leave the number but im not sure how to just read the last one so i can increase it.
I hope someone can help Thankya & luvya all, Jenni x.
Back to
Seekers of Perl Wisdom
|
|