in reply to Predefining complex data structures?

Why do you feel that this needs to be predefined? Or a better question is, how would you go about doing it given that the structure in its nature is open ended? That is to say, the array reference pointed to by the "requirements" key has no built-in limit, nor does there appear to be a maximum number of attributes in the embedded hash. Thus, if you were to predefine it in some way, you'd have to choose an arbitrary depth to which to do so.

As far as push()ing and shift()ing and what not is concerned, this should do it:

push(@{$tagstack{requirements}}, { text => 'foo', attributes => [ 'wha +tever' ] } );

Replies are listed 'Best First'.
Re: Predefining complex data structures?
by Ionizor (Pilgrim) on Jul 12, 2002 at 15:00 UTC

    What I had meant by predefining is just to predefine the structure, not the data itself. If I know the structure of the data, defining an appropriate perl structure to hold it shouldn't be that hard.

    I was having difficulty with the push because it kept trying to push into a hash (d'oh!) and I didn't know the correct syntax to fix it. Thanks!