in reply to Perlish way of doing this
You're storing your data in the wrong structures.
You never use the values in the hash %a; you never use it's lookup ability; and you want to iterate it in order.
Your arrays @a1 and @a2:
By reversing the type of structures used you get:
#! perl -slw use strict; my %a=( AA=>'Y', BB=>'Y', CC=>'Y', DD=>'Y', EE=>'Y', FF=>'Y' ); my @a1=('AA','DD','EE'); my @a2=('AA','BB','CC','FF'); my @a = sort keys %a; my %a1; @a1{ @a1 } = (); my %a2; @a2{ @a2 } = (); print join ',', map{ exists $a1{ $_ } ? $_ : '##' } @a; print join ',', map{ exists $a2{ $_ } ? $_ : '##' } @a; __END__ [11:44:17.92] P:\test>413151 AA,##,##,DD,EE,## AA,BB,CC,##,##,FF
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perlish way of doing this
by kappa (Chaplain) on Dec 08, 2004 at 12:09 UTC | |
by BrowserUk (Patriarch) on Dec 08, 2004 at 12:16 UTC | |
by kappa (Chaplain) on Dec 08, 2004 at 12:21 UTC |