Not sure if this will actually make your code faster, as your node's title seems to imply you want, but here's a much more convenient (imho) way to store all the ranges:
#!/usr/bin/perl use strict; use warnings; my @rangecolors = ( { range => [ 1e-99, 1e-90 ], color => 'orange' + }, { range => [ 1e-90, 1e-80 ], color => 'gold' + }, { range => [ 1e-80, 1e-70 ], color => 'yellow' + }, { range => [ 1e-70, 1e-60 ], color => 'chartreuse' + }, { range => [ 1e-60, 1e-50 ], color => 'green' + }, { range => [ 1e-50, 1e-40 ], color => 'turquoise' + }, { range => [ 1e-40, 1e-30 ], color => 'navy blue' + }, { range => [ 1e-30, 1e-20 ], color => 'lavender' + }, { range => [ 1e-20, 1e-10 ], color => 'purple' + }, { range => [ 1e-10, 1 ], color => 'grey' + }, ); foreach (@rangecolors) { print "Between ", $_->{range}[0], " and ", $_->{range}[1], " we want ", $_->{color}, "\n"; }
Note, you still need to explicitly check 0.
In reply to Re: slow code help
by revdiablo
in thread slow code help
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |