Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Parse XML with Perl regex

by AndyZaft (Hermit)
on Jul 07, 2010 at 21:51 UTC ( [id://848553]=note: print w/replies, xml ) Need Help??


in reply to Parse XML with Perl regex

my %hash; $hash { $info_name } = $it_size;
Would create the hash and fill it as you go, replacing the print line with would create a hash. That answers your question, but I have a feeling you wanted to ask something else.

Replies are listed 'Best First'.
Re^2: Parse XML with Perl regex
by ad23 (Acolyte) on Jul 07, 2010 at 22:01 UTC

    Thanks for your reply!

    I replaced the "print" statement in the above code with your code and am trying to print the hash, like:

    .... } $xmlhash{$info_name} = $it_size; #print "$info_name : $it_size\n"; close(XML); } foreach $k (sort keys %xmlhash){ print "$key: $xmlhash{$key}\n"; }

    I am very sure I am going wrong here, as obviously I cannot print the hash???Also, since I am reading from multiple files I want to print the values in all the files read in??

      Use my $key instead of $k.  And also use strict; use warnings; ...

        Thanks

        Appreciate your help!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-25 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found