in reply to Re: how to seperate array after a certain number of elements?
in thread how to seperate array after a certain number of elements?
It's dangerous to repeatedly add decimal numbers since many of them are periodic in binary and therefore cannot be stored precisely. This includes 0.2.
>perl -le"printf '%.17f', .2 0.20000000000000001
The following is a safer, simpler and easier to read (since "5" actually appears) version of your second snippet:
use List::MoreUtils qw(part); my @array = (1..100); my $i; my @parts = part { ($i++)/5 } @array;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to seperate array after a certain number of elements?
by artist (Parson) on Sep 24, 2007 at 19:12 UTC |