Yeah, my original post was pretty abstract, but that was mainly because I hadn't written any code yet. =]
I'll get down to some helpful details here.

I was coming at the same problem here from a different angle, and in a slightly simplified case. The general, long, drawn out form I'm looking at is this:
#I have some variables, and some ranges. #really it's in a tied hash somewhere. my %hash = { #pretend that this is my tied hash a => "20", b => "yes", q => "1e-14" }; my @range_a = (1..20); my @range_b = ("yes", "no"); #each variable of interest has a foreach loop # to go through the values in it's range foreach my $a (@range_a){ $hash{a} = $a; #other variables may be involved. my $seed = srand($a + 42); my $randomness = rand($seed); #or a function func_1(%hash); foreach my $b (@range_b){ $hash{b} = $b; my $foo = $b + $a; #Then, at the innermost level, do something #There could be any number (probably below 20) # of these loops. my $result = end_func(%hash); } }
I have already solved this with a recursive function and a hash of hashes containing the tied hash keys, the ranges they need to take on, and the statements that go in each layer. This was a little ugly, though, and scoping was interesting, to say the least. I was hoping to reduce the complexity for users dealing with this by objectifying it. My vision was something like this
#create objects in my class my $a = param_class->new(\@range_a, $statements); my $b = param_class->new(\@range_b, $statements); $a->loop( $b->loop( &final_sub(%hash) ) );
That's an ugly generalization, but hopefully that is more telling of where I was going with this rambling.
I'll be back tomorrow to talk more with you all about this.
~MB

In reply to Re^2: Philosophies of Objects by GuidoFubini
in thread Philosophies of Objects by GuidoFubini

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.