in reply to Best Data Structure for passing in multiple arguments to a sub-routine

Since you care about the order you probably want a hash with keys for type, title, and elements which would hold an array reference of hashes which describe child elements. your parameter list (3. above) might also be an array.

Something like this:

make_slide( { title => 'Introduction to Slide Making', type => 'elemental', elements => [ { type => 'pic', path => '...', ... }, { type => 'text box', text => '...' }, ], } );

In particular, I frequently use type coded sub hashes and if test on their types to control how the other args are treated.

Phil

  • Comment on Re: Best Data Structure for passing in multiple arguments to a sub-routine
  • Download Code