Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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

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 learning in the Monastery: (3)
As of 2024-03-28 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found