Your skill will accomplish
what the force of many cannot
Re: I am a beginner for perlby cavac (Deacon)
|on Oct 11, 2011 at 12:08 UTC||Need Help??|
First of all, the hashbang line (first line) shouldn't contain a space between the exclamation mark and the slash, so instead of
it should be
Second, i have the feeling that your code is overly complicated. If you loop $i 10 times and only use the first five times, why loop the 10 times anyway? do/until isn't that readable, if or while could do a better job. The foo: tag and next jump also don't help to clarify the code.
There also seems to be another logical flaw with foo/next/do/until: I'm just not sure what result you expect: Just increment $j until it's greater than 10?.
Ok, given above assumptions, let's try to write an easier version, shall we?
If my assumptions are correct so far, we could just remove variable $i altogether and just increment $j until the result is reached:
Of course, in this simple example, we could also provide a formula to do the same. In this case, instead of hardcoded numbers 10 and 2 i'll use $minimum and $stepsize:
While the last solution looks more complicated, it scales better. Think is you don't have 10 steps but 10 billion. The formula would still take the same time while the loop constructs will run for a long time.
Hope that helped to clarify a bit and i didn't misunderstand your problem.
Don't use '#ff0000':
use Acme::AutoColor; my $redcolor = RED();
All colors subject to change without notice.