Re: XML or Storable?
by perrin (Chancellor) on Apr 02, 2002 at 23:22 UTC
|
Simple: XML is language independent, Storable is faster and smaller. Additionally, XML will improve your resume (or CV) more, Storable will get your project done sooner (because it's a dirt simple interface and you already know how to use it). | [reply] |
Re: XML or Storable?
by jepri (Parson) on Apr 03, 2002 at 02:01 UTC
|
XML gives me a sick headache every time I work with it. Storable, as you know, just works.
If you think there would be any chance that someone else would try and interface with your program via data structures, you would probably want to give XML a shot. If that's not an issue, Storable is clearly the best.
They are both non-core modules wrapped around C libraries, so I don't think there's any particular convenience to using one over the other.
____________________
Jeremy
I didn't believe in evil until I dated it. | [reply] |
Re: XML or Storable?
by Maclir (Curate) on Apr 03, 2002 at 03:36 UTC
|
Storable preserves the internal representation of Perl data structures. It is fast, efficient and simple to use.
XML provides a language / platform / application independant method for information (that is - data with structure and contextual meaning associated with it) passing. I suspect that at present, it has none of the three attributes Storable has - implementing an XML solution would result in a program that is slow, inefficient and be complex to write and maintain.
Bottom line: How quickly do you need the solution? If you need it today, stick with storable. Do you need to pass the information to other application? Bite the bullet and learn XML - it is the "solution to all our problems" de jour (sorry for the cynical comment, I just conldn't resist). | [reply] |
Re: XML or Storable?
by gav^ (Curate) on Apr 03, 2002 at 00:21 UTC
|
Storable is fantastic. I use it regualarly as a read-only data source to save an intermediate stage when processing data. It loads 10 meg+ files in a snap. I'm sure you'd find an XML dump a lot slower.
gav^ | [reply] |
Re: XML or Storable?
by kappa (Chaplain) on Apr 03, 2002 at 10:43 UTC
|
I think your could achieve both goals at once. Try XML::Dumper which is just a serializer (as Storable) into XML. | [reply] |
Re: XML or Storable?
by Matts (Deacon) on Apr 03, 2002 at 12:39 UTC
|
I'd probably go for Storable, unless your data has to be accessible in places other than perl.
If it does (need to be accessed by other languages), would I use XML? I'm not sure... I tend to focus on XML (the syntax) being either a long-term storage format, or a transport format. Or I use XML (the data format) as an intermediary system for giving me access to great tools (e.g. using XML::Generator::DBI so I can use XML tools with databases).
So if you don't know XML, and want some form of cross-platform short-term storage format, I'd use a database. It'll be faster and easier to use for you.
But if you don't need all that cross platform gubbins, and the cool tools XML gives you don't grab you, then use Storable. It rocks, and it just plain works.
(And yeah, this is from a guy who lives and breathes XML) | [reply] |
Re: XML or Storable?
by Caillte (Friar) on Apr 03, 2002 at 10:38 UTC
|
I have just finished a big bit of coding which, if I had
used storable would have taken much less time. However, I
had to choose XML for two reasons... firstly because there
was also a VB interface for part of it and, secondly, because
I wanted to try XML.
Now I have tried it I can say I think it is an over-rated
language, but one that does have it's merits. Now I am aware
of that I know for what I would use it for. Config files for a start
and interfacing with other languages as it has become a standard.
However, I will be prefering storable still, and probably will for many years to come
This page is intentionally left justified.
| [reply] |
Why not both!?
by grantm (Parson) on Apr 03, 2002 at 13:24 UTC
|
Storable is probably the answer to your specific problem.
One advantage of XML is that it's possible to edit the
serialised form - may be handy in the odd situation.
If you use XML::Simple, writing the serialised form to XML
is essentially a one line call to XMLout(). In recognition
of the fact that parsing XML is probably slower than
slurping in Storable data, XML::Simple can
transparently 'cache' the parsed version using Storable.
One disadvantage of XML::Simple is that it won't work with
blessed references. | [reply] |
Re: XML or Storable?
by Anonymous Monk on Apr 03, 2002 at 14:42 UTC
|
I guess, Storable might help you much better than XML-dump. It's faster, takes less RAM (at least with normal usage) and if you really want, you can also make the dump plattform independend.
Best regards,
ls
| [reply] |
Re: XML or Storable?
by moodster (Hermit) on Apr 03, 2002 at 15:22 UTC
|
For read-only access (such as config files or static data), I tend to use XML::Simple, which is a gem of a module. It happily parses large XML files and spits out an anonymous hash or array with your data formatted the way you expect. Excellent. And to make things even better, it has locking support and will cache the parsed XML tree as a separate file using (you guessed it) Storable! You get the best of two worlds: human-readable files that are lighting fast to load.
However, for complex read/write-operations I wouldn't recommend reading and writing entire XML files. Maybe you should go with a mixed solution and put your Storable objects in a DB_File?
Cheers,
--Moodster | [reply] |