[ale] Converting C data structures for use in perl

Christopher Fowler cfowler at opsup.com
Mon Apr 21 19:33:45 EDT 2003




Hello,

I've got my data parsed and having a issue try to make it accessible throughout the
program.


Here is a refernce in C

struct device {
  char *name;
  char *user;
  char *pass;
}

struct unit {
    char ip;
    struct device **d; 
};

struct unit **unit; // Array of units

I've tried in perl:

$units{'127.0.0.1'}{'D1'} = { user => "root", pass => "pass");
$units{'127.0.0.1'}{'D2'} = { user => "root", pass => "pass");

But, I think I need an array so I can walk it later in a for loop.
Plus, I nee the flexibility to add more variables to the unit structure.

I think I need a mater array that contains and array of unit hashes.  Each
unit hash contains an array of device hashes.  To me, this seems a little
complex.  Is it the best solution?  What would be a better solution.

I'm not parsing an XML file and I just need to dump the attributes into a data
repository so I can use it later.  That is what I'm trying to accomplish
now.

Thanks,
Chris



_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list