On 5/19/05, Scott Taylor wrote:
> 
> ... to pump out lines of data to my SQL statement.
> 
> I'll need to end up with something like:
> qw($vid,$eid,$event,$desc
>   ,$date,$mid_desc,$mid_val
>   ,$pid_desc,$pid_val,$min,$max,$val)
> 
> for each line of data. (or whatever works)
> 
> I think I'm just lost at the nested hash (if that's what it's called)
> thingy, and how to work with it. :|
> 

It's a data structure, consisting of references to hashes and to arrays.
To begin with, start by reading tutorials such as:
http://perldoc.perl.org/perlreftut.html - references tutorial
http://perldoc.perl.org/perldsc.html - data structures cookbook

Once you've mastered the basics, you should be able to understand
these two statements:
$vid = $ref->{'vid'};
$pid_val = $ref->{'j1587'}->{'data'}->[0]->{'pid'}->{'val'};

These are just examples. To get at all the data in an organized way,
you'll need to wrap calls such as the above in loops-within-loops,
depending on how deep your data structure is.
Of course, after a while you might get tired of manually looping over
your data. In that case I suggest you start looking at XML modules
that provide OO access methods to your data, such as XML::SimpleObject
:
http://search.cpan.org/dist/XML-SimpleObject/SimpleObject.pm

That's just a suggestion, there are of course many others out there :-)

HTH,
-- 
Offer Kaye

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to