Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: How to export hash to xml file

by Sombrerero_loco (Beadle)
on Jan 14, 2009 at 12:03 UTC ( #736204=note: print w/replies, xml ) Need Help??


in reply to Re: How to export hash to xml file
in thread How to export hash to xml file

cool, but this examples shows how write a "small" and "declared" hash, i have a big one with the structure i told you with around 5000 keys with his values. So i need to way to give something like a :
foreach $control_key (%my_huge_hash)
and use the $control_key to walk in the hash and make the xml. In all the examples i saw, all the FAQs and tutorials told me how i can do that with a small hash (with the values declared). I have in every hash key a variable that imports from a while loop that reads a text file to this hash . Thanks!

Replies are listed 'Best First'.
Re^3: How to export hash to xml file
by zentara (Archbishop) on Jan 14, 2009 at 12:28 UTC
    Maybe you can use this example as a base:
    #!/usr/bin/perl use warnings; use strict; # by jdporter of perlmonks, converts a dir tree to xml use File::Find; use XML::Simple; #my $root = shift or die "Usage: $0 rootdir\n"; my $root = shift || '.'; my %tree; find( sub { #print "$File::Find::name\n"; my @path = split m,/,, $File::Find::name; my $tree = \%tree; $tree = (($tree->{'dir'} ||= {})->{shift @path} ||= {}) while @path > ( -d _ ? 0 : 1 ); @path and # it's a file push @{ $tree->{'file'} ||= [] }, shift @path; }, $root ); print XMLout( \%tree );

    I'm not really a human, but I play one on earth Remember How Lucky You Are

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2022-08-17 11:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?