in reply to Re: Re (tilly) 3: How to pass a variable to function selected from a hash
in thread How to pass a variable to function selected from a hash

Yup, looks like you got it all. Other than the missed join in your print. And the return on the next line. Oh, and the fields in question were actually printed on the first line, but that is neither here nor there. :-)

Repeated nested lookups happen at runtime in Perl, and you can often get signficant speedups by factoring them out of loops. Also I have found that just creating temporary variables for them makes the mechanics of the code less of a problem, and clarifies what it is doing.

BTW the original example actually created a set of reports, with different sets of fields. And some of the fields themselves were the result of complex calculations. (Many of which resembled each other and...but I digress.) Being able to move the logic off to elsewhere considerably simplified the overall design and made minor tweaks and changes a lot easier to implement. The basic idea was indeed a good fit, even if it was not a good way to first meet this approach. :-)

UPDATE
Oops, you did indeed get the join correct. And even commented it. I missed that last night, sorry.

  • Comment on Re (tilly) 5: How to pass a variable to function selected from a hash