Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: best way to change xml record using XML::Simple?

by seattlejohn (Deacon)
on Feb 24, 2003 at 20:21 UTC ( #238219=note: print w/replies, xml ) Need Help??


in reply to best way to change xml record using XML::Simple?

As others have mentioned, XML might not be the most straightforward or efficient solution to this problem -- but since you've already got working code here's a thought as to how you could evolve it. Check out some of the options in XML::Simple that control the way XMLin folds the generated data structure. Using keyattr, you ought to be able to set things up so that the data structure ends up with UID as a hash key. That would let you remove the loop that searches for the matching UID, something simple like this (untested, and dependent on your exact data structure):
$xref->{record}->{$newnode->{uid}} = $newnode;

Also, I would tend to avoid the four-digit zero-padded UIDs in favor of simple integers, which are less work to generate and also don't cause potential problems when you add your 10,000th contact -- though I hope that if you do have 10,000 contacts, you'd have begun using a real database rather than an XML file at that point :-)

        $perlmonks{seattlejohn} = 'John Clyman';

Replies are listed 'Best First'.
thank you!
by waxmop (Beadle) on Feb 24, 2003 at 20:49 UTC

    your comment was exactly what I was hoping for. I'll play with the keyattr to avoid the loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://238219]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-01-29 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?