mkirank has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl 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(@tmp1,@tmp2); foreach my $xx (sort (keys(%a))) { $a = grep (/$xx/, @a1); $b = grep (/$xx/, @a2) ; if (($a && $b) || (!$a && !$b)) { push (@tmp1,$xx); push (@tmp2,$xx); } elsif ($a && (!$b)) { push (@tmp1,$xx); push (@tmp2,'##'); } elsif (!$a && ($b)) { push (@tmp1,'##'); push (@tmp2,$xx); } } print join(',',@tmp1); print "\n"; print join(',',@tmp2); print "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perlish way of doing this
by BrowserUk (Patriarch) on Dec 08, 2004 at 11:50 UTC | |
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 | |
|
Re: Perlish way of doing this
by fglock (Vicar) on Dec 08, 2004 at 11:54 UTC | |
|
Re: Perlish way of doing this
by htoug (Deacon) on Dec 08, 2004 at 11:44 UTC | |
by htoug (Deacon) on Dec 08, 2004 at 12:53 UTC | |
|
Re: Perlish way of doing this
by Random_Walk (Prior) on Dec 08, 2004 at 12:08 UTC | |
by Random_Walk (Prior) on Dec 08, 2004 at 14:50 UTC | |
|
Re: Perlish way of doing this
by kappa (Chaplain) on Dec 08, 2004 at 11:40 UTC | |
|
Re: Perlish way of doing this
by mkirank (Chaplain) on Dec 08, 2004 at 12:48 UTC | |
|
Re: Perlish way of doing this
by dave_the_m (Monsignor) on Dec 08, 2004 at 11:15 UTC | |
by mkirank (Chaplain) on Dec 08, 2004 at 11:27 UTC |