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"; }
In reply to Re^2: condensing code
by derby
in thread condensing code
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |