[ale] Converting C data structures to Perl

Chris Fowler cfowler at outpostsentinel.com
Mon Apr 21 21:15:19 EDT 2003


No,

The problem is that I think in complex data structures such that I can
perform in C and Java.  The example was an example in which I've done in
C.  I want to do something similar in Perl.  Every page I'm reading
states that you can not do  complex data structures in Perl.  It C
example is what I would normally do.

master array ---
               |--> unit
                       -> IP Address
                       -> device
                        |-> name
                        |-> pass
                      -> device
                        |-> name
                        |-> pass
              |-> unit
                      -> IP address
                      -> device
                        |-> name
                        |-> pass

In perl this would be an array of hashes which contain and array of
hashes.  Is this too complex for perl.  Sure you can do it with 1000
variables, but it needs to be referenced within one tree like above.

                                               
On Mon, 2003-04-21 at 20:57, Fletch wrote:
> >>>>> "Christopher" == Christopher Fowler <cfowler at outpostsentinel.com> writes:
> 
>     Christopher> Hello,
> 
>     Christopher> I've got my data parsed and having a issue try to
>     Christopher> make it accessible throughout the program.
> 
> Erm, if it's parsed in perl then why are you talking about C
> structures . . . /me is confuzlled . . .
> 
>     Christopher> Here is a refernce in C
> 
>     Christopher> struct device { char *name; char *user; char *pass; }
> 
>     Christopher> struct unit { char ip; struct device **d; };
> 
>     Christopher> struct unit **unit; // Array of units
> 
> If you really do have it as C pointery-fun data you could use unpack
> and some deep wizardry, but for something as involved as this it'd
> probably be much easier to write your own API using either XS or
> Inline::C.  Start with perldoc perlxstut and perldoc perlxs for the
> former, or look for the Inline documentation on search.cpan.org for
> the later (which might be easier to pick up).
> 
> 
> -- 
> Fletch                | "If you find my answers frightening,       __`'/|
> fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
> 770 294-0820 (m)      |  scary questions." -- Jules                =(___)=
>                       |                                               U
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale


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





More information about the Ale mailing list