http://www.perlmonks.org?node_id=931539


in reply to Re: How to access a hash from another file
in thread How to access a hash from another file

Yes and no. If the logic gets torturous I find it better just to create a table even if it is almost wholly repetitive. If it is large (or small), if most entries are the same or even empty. Perl doesn’t mind tedious.

As soon as there are nots, ors and ands and they start nesting and cascading all over the place I’m certain, nay, guaranteed, to get it wrong. I find it hard to write, the bugs hard to find and they are most often the sort of bugs that appear six months down the line. Did I mention my boolean algebra is weak?

If it is appropriate and I can fit the logic into a table I get on much better, it is all reduced to a lookup. If it is not appropriate then yours is the way to go. What is appropriate, of course, is a matter of taste. :-)

  • Comment on Re^2: How to access a hash from another file

Replies are listed 'Best First'.
Re^3: How to access a hash from another file
by tospo (Hermit) on Oct 14, 2011 at 16:48 UTC
    well, Perl doesn't mind tedious but you might and you are likely to get nice little errors in the long table that will be difficult to find. Why risk it? It's like wanting to print out a multiplication table by hardcoding all the results instead of calculating them. Yes, you can do it and Perl doesn't mind but it would defeat the purpose, wouldn't it?