reluctant_techie has asked for the wisdom of the Perl Monks concerning the following question:
My code thus far is
This program successfully compares the arrays but returns "Supported" if there is any match in @SupportedPTs for a value in @ProblemTypes. I am having trouble thinking this through. Any help would be appreciated.my @SupportedPTs = ('Accounting','Dnd','Essay','FITB','Hotspot','Match +ing','MC','Narrative','SingleAnswer','SelfGradingGeneric','Sketch','S +tatic','TF'); my @ProblemTypes = ('Accounting','Dnd','test'); my %seen = (); foreach (@ProblemTypes) { $seen{$_} = 1; } if (grep ($seen{$_}, @SupportedPTs) ) { print "Supported\n"; } else { print "Unsupported\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing arrays and returning false if an exception is found
by oko1 (Deacon) on Apr 16, 2008 at 23:26 UTC | |
|
Re: Comparing arrays and returning false if an exception is found
by ysth (Canon) on Apr 17, 2008 at 00:18 UTC | |
|
Re: Comparing arrays and returning false if an exception is found
by pc88mxer (Vicar) on Apr 16, 2008 at 23:21 UTC | |
|
Re: Comparing arrays and returning false if an exception is found
by toolic (Bishop) on Apr 16, 2008 at 23:37 UTC | |
|
Re: Comparing arrays and returning false if an exception is found
by citromatik (Curate) on Apr 17, 2008 at 11:48 UTC | |
by ysth (Canon) on Apr 17, 2008 at 16:32 UTC |