Aug 28, 2013, 7:01 AM
Post #6 of 6
The first problem is that you're manually parsing an xml file with a regex instead of using an XML parser. If the xml data is simple enough, then a simplistic regex approach can work, but is a very fragile approach.
Re: [jayasree] Sequence Number
[In reply to]
Why are you opening "Process.out" in a loop? That doesn't make any sense.
$Process1 is declared, but never assigned a value, so attempting to open a filehande to "$Process1.out" isn't going to be very fruitful.
You should ALWAYS check the return code of an open call to make sure it was successful and take action if it wasn't. You can do that test explicitly on each open call, or you can use the autodie pragma which will do that check for you.
When opening a filehandle, you should use a lexical var for the handle instead of a bareword. The bareword writefile that you used for the handle is what the first error message is referring to. If you had written that in uppercase, perl would not have complained but you should use a lexical var instead.
Don't use the C style for loop syntax. It's cleaner and more efficient to use perl's for loop syntax.
Do you want to use the existing id numbers and just format them with leading zeros, or do you want as is implied in your code to replace them with a new sequential (formatted) number even if it's not the same value as the original?