Re: equivalent controls



Wade Ward wrote:
[...]
do {{
$x_calc++;
$power++;

last if $x_calc > 10;
print STDOUT "x calc is $x_calc\n";
print STDOUT "x_calc out is $x_calc\n";
print STDOUT "power out is $power\n";
do {{
$power++;
$x_calc++;
print STDOUT "power in is $power\n";
print STDOUT "x_calc in is $x_calc\n";
$x_sought = $x_sought - 1;
last if 1 > 0;
print STDOUT "x sought is $x_sought\n";

}} until $x_calc > 7.5;
$x_calc = $penultimate;
}} until ($power > 6);
[...]
Is there a slicker way to do this in perl than using the double curly
braces?

Absolutely, here it goes for your main loop:

while ($power < 6 and $x_calc < 10) {
$x_calc++;
$power++;
print "x calc is $x_calc\n";
print "x_calc out is $x_calc\n";
print "power out is $power\n";
while ($x_calc <= 7.5 ){
$power++;
$x_calc++;
print "power in is $power\n";
print "x_calc in is $x_calc\n";
}
$x_calc = $penultimate;
};

It also reduced the number of lines from 20 to 14 and IMHO is much more
readable, too.

jue


.



Relevant Pages

  • Re: equivalent controls
    ... print STDOUT "power out is $power\n"; ... use warnings; ... print STDOUT "current is $penultimate \n"; ...
    (comp.lang.perl.misc)
  • equivalent controls
    ... print STDOUT "power out is $power\n"; ... x calc is 6.3 ... # end output prelims begin comment ...
    (comp.lang.perl.misc)