|Do you know where your variables are?|
Looking for suggestions, sorting data from XML or JSONby johnfl68 (Beadle)
|on Jul 06, 2013 at 05:26 UTC||Need Help??|
johnfl68 has asked for the
wisdom of the Perl Monks concerning the following question:
I need to rewrite some code, and probably almost a complete rewrite at that.
I am getting Arrival and Departure data for an airport, currently in XML, but I can also do JSON. This contains other information besides the flightStatus's (see example):
Part of the problem is currently the data is being sorted by XML::Simple by the 3 letter Airport code, and I really need things sorted by Arrival/Departure times.
I admit I am not the best when it comes to working with hashes and arrays, but willing to try and learn if pointed in the right direction.
As I am on a shared server, it is often a bit of work getting things added, so I am working with core modules, plus I have XML::Simple and JSON::XS as well. The only reason I bring this up, is often people here offer up all these other modules that are not part of the core. That is fine if you are on your own server and can easily add what you want. It's not quite that easy on a shared server unfortunately.
Everyone seems to be going the JSON route these days, so probably rewrite in JSON unless there is a reason to go with XML I guess.
If I somewhat understand correctly, the best option would be to load the hash data from the XML/JSON into an Array, which will make sorting easier? Is this the best route to go?
Does anyone know of a good place to start with examples of how to best go about loading things into an array, and then sorting, if that is the best way?
Again, thank you for your help and guidance as always.