|laziness, impatience, and hubris|
Comment onby gods
|on Feb 11, 2000 at 00:06 UTC||Need Help??|
You can probably simplify the top by doing the following:
Note that if you need defaults, you could also define these with the same keys as above in %prop_def, and then the marked line becomes:
Update on your second part. Unfortunately, getting the values out of @_ gets messy fast. Some other possible options:
Use a hash to pass values in. This allows not only for later expansion without breaking the routines, but also for default values on your end. However, it's hard to do any compile-time checking for right parameters. EG:
Taking a cue from the example above, use defencing of shifts to get your variables without the extra variable. You can still do some compile-time checking, but again, if you need to update the code, you might break other users code.
Since all you seem to be doing is taking arguements and using that to pump out a text file for VRML, without doing any major processing of the code, you *may* want to consider using somelike like Template Toolkit 2, along with the hash argument suggestion, to make it easier to keep the perl code and VRML generatation separate.
Note that I can see a nice way to tree all your data, and use a single call to TT2 to get everything out in one go, but that's probably beyond the scope of the help you are requesting.
Update 2 - fixed an if condition above, thanks chipmunk!
Dr. Michael K. Neylon - firstname.lastname@example.org || "You've left the lens cap of your mind on again, Pinky" - The Brain
In reply to Re: Optimizing variable passing (code, peer review)