in reply to Re: Running a subroutine a certain number of times
in thread Running a subroutine a certain number of times

Also, you almost certainly don't need those old C-style for loops. and actually, you don't need those $i variables at all.

$number_of_sequences=12; $max_length=50; $min_length=30; my @set; foreach (0 .. $number_of_sequences) { my $aminoseq = genseq($aminoseq); print "$aminoseq\n\n"; push (@set, $aminoseq); } sub genseq { my $leg = randomlength(); my $seq; foreach (0 .. $leg) { $seq .= randomaminoacid(); } return $seq; }
or even
sub genseq { my $seq; $seq .= randomaminoacid() foreach 0 .. randomlength(); return $seq; }
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: Re: Running a subroutine a certain number of times
by dreadpiratepeter (Priest) on Aug 05, 2002 at 15:34 UTC
    I definitely agree. I just didn't want to take his code too far astray. Plus, it's really hard to demonstrate scoping problems while removing all the variables that are causing the scoping problems.

    -pete
    "Pain heals. Chicks dig scars. Glory lasts forever."