LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2007, 04:32 PM   #1
Jorophose
Member
 
Registered: Oct 2006
Location: Ontario, Canada
Distribution: Xubuntu 6.06!! =D
Posts: 137

Rep: Reputation: 15
XML::Simple


Is it possible to parse something in XML into a perl hash like once, and make any future refference to the hash and not the XML? Like, create a totally new hash file (like .jor) to replace each XML file, keeping the same name, and then if the hash file is missing, look for the XML file and parse that?

I'm a bit new to this, and the only guides I find are for parse-right-now-and-keep-in-the-script sort of situation.
 
Old 09-24-2007, 01:32 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Tie the hash to to a file: http://perldoc.perl.org/functions/tie.html
 
Old 09-26-2007, 11:01 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Personally, I happen to be of the opinion that tie is a feature that is most-often abused, to the serious detriment of the program(s) in question...

To my way of thinking, you should imagine that you are fundamentally dealing with an object, whose solitary purpose in life is to enable you to work with "a Perl 'hash'" that is somehow sourced from "an XML file" (in a fashion that is known only to the object).

So... the basic "method" exposed by this object [class] will be one that, given a key, returns the value corresponding to that key ... exactly as a hash would do. But it has an awareness that "its values come from such-and-such a file," and therefore that if it has not yet loaded that file into memory it should first do so."

Any programming language .. but especially a language like Perl .. challenges you to strike an appropriate balance between "what" and "how." That balance should usually be resolved in favor of "what," but the language (like Perl) might instead try to tilt your judgement (quite erroneously...) in favor of "how." It's a bias that is very hard to shake.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't locate XML/Simple.pm in @INC (@INC contains RaleighRalley Linux - Newbie 5 12-13-2013 05:43 PM
LXer: XML::Simple for Perl developers LXer Syndicated Linux News 0 02-04-2007 08:21 AM
LXer: StAX’ing up XML: Streaming API for XML LXer Syndicated Linux News 0 11-30-2006 07:54 AM
configure: error: could not find DocBook XML DTD V4.1.2 in XML catalog Fadoksi Linux - Software 1 07-16-2006 06:41 AM
Perl XML::Simple - Hash Question smaida Programming 2 05-26-2004 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration