in reply to Very Large Hex Combinations
People have suggested ways of working with numbers. I think it's faster to work with strings in this case (because it reduces greatly the number of calls to sprintf):
my @bytes = map { sprintf('%02X', $_) } 0..255; foreach my $i (@bytes) { foreach my $j (@bytes) { foreach my $k (@bytes) { foreach my $l (@bytes) { foreach my $m (@bytes) { foreach my $n (@bytes) { print("$i$j$k$l$m$n\n"); }}}}}}
Or you could use NestedLoops in Algorithm::Loops:
use Algorithm::Loops qw( NestedLoops ); my @bytes = map { sprintf('%02X', $_) } 0..255; my $num_bytes = 6; NestedLoops( [ ( [ @bytes ] ) x $bytes ], sub { print(join('', @_), "\n"); } );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Very Large Hex Combinations
by danambroseUK (Beadle) on Aug 04, 2005 at 15:08 UTC | |
by ikegami (Patriarch) on Aug 04, 2005 at 15:14 UTC | |
by Taulmarill (Deacon) on Aug 04, 2005 at 15:18 UTC | |
by ikegami (Patriarch) on Aug 04, 2005 at 15:21 UTC | |
by danambroseUK (Beadle) on Aug 04, 2005 at 15:41 UTC | |
by abell (Chaplain) on Aug 04, 2005 at 15:54 UTC | |
by Anonymous Monk on Aug 04, 2005 at 16:23 UTC | |
by ikegami (Patriarch) on Aug 04, 2005 at 16:41 UTC | |
| |
by polettix (Vicar) on Aug 04, 2005 at 16:42 UTC | |
by danambroseUK (Beadle) on Aug 04, 2005 at 17:11 UTC | |
| |
by BrowserUk (Patriarch) on Aug 04, 2005 at 16:27 UTC | |
by Anonymous Monk on Aug 04, 2005 at 16:44 UTC | |
by tall_man (Parson) on Aug 04, 2005 at 21:20 UTC | |
by ikegami (Patriarch) on Aug 04, 2005 at 16:17 UTC | |
by Anonymous Monk on Aug 04, 2005 at 16:28 UTC | |
|
In Section
Seekers of Perl Wisdom