On 4/10/06, Jay Savage <[EMAIL PROTECTED]> wrote:
> On 4/10/06, Ed <[EMAIL PROTECTED]> wrote:
> > Thanks guys!
> >
> >  I've been reading everything I can about Perl and although I've read
> > Learning Perl, and have been referencing Programming Perl, The Perl
> > CookBook, Modern Perl Programming and using the Perl Debugger mini
> > book, I must say, there's alot about Perl I don't yet understand. All
> > I know so far is it's amazingly powerfull and up until I started
> > trying to create a structure, I thought it was pretty straightforward.
> >
> > A couple things:
> > 1. What's "od HoA" ??
>
> heh. It's a typo. It was supposed to be "a plain *old* HoA. HoA is
> hash of arrays.
>
> > 2. I know you don't remove use strict to eliminate errors!! (jeez)
> > 3. What is the alternative to Class::Structs if I want to create some
> > "data aggregates"? od Hoa?
> >
> > One book I have (Modern Perl Programming, Saltzman 2002) has some good
> > stuff in Chapter 11 (Object Oriented Programming) I'm investigating.
>
> Perl allows for arbitrarily complex data structures. Class::Struct is
> one way to interface them, when you need to emulate a C struct. If
> you've got it working for you, run with it. It's extremely powerful,
> but also, as you've found out, not terribly intuitive if you're not a
> C programmer. Objects are another useful way, depending on your
> circumstances (do you want inheritence, etc.?). You can also use what
> are called anonymous hashes and arrays or refernces to build up data
> structures. The spirit of "There's more than one way to do it" extends
> to data structures in a big way. For example, a hash of arrays:
>
>     mt %hoa = ( #parenthesis, not bracket
>         one => ["one","un","uno","1"],
>         two => ["two","deux","dos',"2"]
>     );
>
>     print $hoa{'one'}->[0]; # gets one
>
> you can do the same thing with hashes of hases, arrays of arrays, etc., e.g.:
>
>     my %hoh = (    # parenthesis, not bracket
>         '1' => { english => "one",
>                   french => "un",
>                   spanish => "uno" },
>         '2' => { english => "two",
>                    french => "deux",
>                    spanish => "dos"} );
>
>     print $hoh{'1'}->{'english'}    # gets one
>
> You can also mix and match one hash element can be an array reference,
> and another a hash reference, etc. The possibilities are pretty much
> endless, but this should all be in chapter 9 of Programming Perl. Look
> for "Hash of Hashes," "Hash of Arrays," "Array of Arrays," etc., and
> also "anonymous hashes," "anonymous arrays," "array references," and
> "hash refeneces."
>
> HTH,
>
> -- jay
> --------------------------------------------------
> This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
> private and confidential
>
> daggerquill [at] gmail [dot] com
> http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org
>
> values of β will give rise to dom!
>


--
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to