Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: writing an address book program

by andreychek (Parson)
on Jun 07, 2001 at 00:48 UTC ( #86387=note: print w/replies, xml ) Need Help??

in reply to writing an address book program

Data::Dumper and MLDBM would work quite well. However, this would
also be an excellent opportunity to make use of some XML.

In an XML file, you could simply say:
<addys> <reallyhotchick> <phone>555.555.5555</phone> <name>Jane Shmoe</name> <cell>555.555.5555</cell> <nick>reallyhotchick</nick> </reallyhotchick> </addys>
There are quite a few Perl modules at CPAN
which will parse an XML file for you. You can just go
there and do a search for 'XML'. I have in the past found
XML::Simple, XML::TokeParser, and XML::Twig to be useful.
Those three all use XML::Parser to do their dirty work.

If you're feeling particularly adventurous, you could always
try and use XML::Parser directly. However, most of what you may
want to do has already been implemented, and no need to
reinvent the wheel unless you're trying to learn how
something works :-)

Good Luck!

Replies are listed 'Best First'.
Re: Re: writing an address book program
by mexnix (Pilgrim) on Jun 07, 2001 at 00:54 UTC
    I hadn't thought of XML. I've actually been meaning to take a serious look at XML too. Thanks a bunch! Now I if I could only learn through osmosis...

    %mexnix = (email = > "", website => "");

      Osmosis.... MMmmmmmm... :-)

      Yeah, I actually picked up XML not too long ago myself.
      With the method you mentioned you are looking to use, XML::Simple
      might be your best bet.. you just point it to a XML
      file, and it will slurp the thing in and make it a
      hash of hashes (...of hashes of hashes, etc).

      However, just think how big this thing might get.. slurping the whole
      address book into a hash is loads of fun, but you might regret it later ;-)
      But you have to start somewhere, and XML::Simple is.. well.. simple :-) Have fun,

      There's an XML tutorial I found useful at w3schools, it's not Perl-related but a good intro to the world of XML.

      Update: After a comment by Beatnik I realised I should have included a link directly to the XML tutorial: here it is

      Kevin O'Rourke
        In addition to the excellent XML tutorial Kevin mentioned,
        there is actually an XML::Parser tutorial located
        on PerlMonks that may help you get started if you are interested
        in working with XML::Parser, and not one of the higher level
        modules mentioned previously.

        Along with the useful tutorial provided at that node, it also contains the
        usual array of intelligent comments and code one often finds on this site.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://86387]
[james28909]: i have discovered hash of arrays

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2017-04-27 19:17 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (512 votes). Check out past polls.