in reply to confusing array comparison
Would something like this work?
#! perl -slw use strict; use List::Util qw[ shuffle ]; our $N ||= 10; our $E ||= 5; my @a = (shuffle 1 .. $N)[ 0 .. $E ]; my @b = (shuffle 1 .. $N)[ 0 .. $E ]; my @c = (shuffle 1 .. $N)[ 0 .. $E ]; my @d = (shuffle 1 .. $N)[ 0 .. $E ]; my %comp; $comp{ $_ }{a} = 'a' for @a; $comp{ $_ }{b} = 'b' for @b; $comp{ $_ }{c} = 'c' for @c; $comp{ $_ }{d} = 'd' for @d; print " : a b c d\n--------------"; printf "%4s : %s\n", $_, join ' ', map{ $_||'-' } @{ $comp{ $_ } }{ 'a'..'d' } for sort{$a<=>$b} keys %comp; __END__ c:\test>528473 : a b c d -------------- 1 : - - c - 2 : a - c d 3 : a b - - 4 : a b c - 5 : a b c d 6 : a b - d 7 : - b - d 8 : - - c d 9 : - - c - 10 : a b - d c:\test>528473 -N=10 -E=8 : a b c d -------------- 1 : a - c d 2 : a b c d 3 : a b c d 4 : a b - d 5 : a b c d 6 : a b c d 7 : a b c d 8 : - b c - 9 : a b c d 10 : a b c d
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: confusing array comparison
by Anonymous Monk on Feb 07, 2006 at 12:40 UTC | |
by BrowserUk (Patriarch) on Feb 07, 2006 at 13:17 UTC | |
|