Don't ask to ask, just ask | |
PerlMonks |
Re: ReadParse and Hash Valueby roboticus (Chancellor) |
on Nov 07, 2014 at 12:33 UTC ( [id://1106484]=note: print w/replies, xml ) | Need Help?? |
As has been mentioned, if you care about the order, then a hash may be the wrong data structure to use. But if you're in control of the form as well, then the order isn't important--since you built the form, you know the correct order. So just grab the data items from the hash in the order you want to print them:
So you could modify your write_file routine to do it that way. If you're using write_file for multiple forms, then you could modify write_file to accept a list of field names so you can specify the order, kinda like this:
This change lets you pass in the order you want to write_file, and if you don't specify the order, it will print them the same as it does now (i.e., whatever order the hash chooses). This lets you change the write_file routine without breaking it for everyone else. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|