in reply to Re: file handling error
in thread file handling error
My “wisdom” on this issue is that ... there ought to be a big sign pasted over the doorway that leads to “the way you’re trying to do it now.” That sign would read:
Through me you pass into the city of woe:
Through me you pass into eternal pain:
Through me among the people lost for aye.
Justice the founder of my fabric mov'd:
To rear me was the task of power divine,
Supremest wisdom, and primeval love.
Before me things create were none, save things
Eternal, and eternal I endure.
All hope abandon ye who enter here.
“The right way to do it ... the only way to do it ...” is with an XML parser (package from CPAN). If you take something like, say, XML::Simple, this will be able to parse the XML into a hashref structure. You can then manipulate that structure any way you need to. Then, write it out.
When writing processing routines like this, I always try to follow two principles: