in reply to Re: condensing code
in thread condensing code
That was my initial thought but that would make 30 => 2 and not 1. So I think he wants int( ($num-1) / 30 ) + 1.
#!/usr/bin/perl use strict; use warnings; my @nums = ( 1 .. 1000 ); foreach my $num ( @nums ) { my $test_n = int( ($num-1) / 30 ) + 1; print "Num: $num - $test_n \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: condensing code
by ptum (Priest) on Sep 08, 2006 at 18:02 UTC | |
by derby (Abbot) on Sep 08, 2006 at 18:21 UTC | |
by ptum (Priest) on Sep 08, 2006 at 20:00 UTC |