in reply to Re^2: Buffering and output help needed
in thread Buffering and output help needed
You'll want to create a list of matching variables to return. You could do it a bit like this: (code clarified a bit)
use strict; use warnings; sub incStart { my ($start,$end,$mod) = @_; my @result; for ( my $x = $start ; $x < $end ; $x++ ) { if ( ( $x % $mod ) == 0 ) { push @result,$x; # append $x to result list } } return @result; # <- return AFTER completing the loop } print "test "; foreach my $result (incStart(0,10,3)) { print "$result\n"; }
Please also be very careful about where you define variables and use strict and warnings.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Buffering and output help needed
by richill (Monk) on Oct 07, 2006 at 13:42 UTC |