Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by philcrow (Priest)
on Mar 13, 2007 at 15:45 UTC ( [id://604584]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://604584]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-25 16:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found