Discipulus has asked for the wisdom of the Perl Monks concerning the following question:
greetings freom sunny romaforeach $aa (@ARGV) { if ($aa=~/^peace$/) {$cond[0]='peace'; push(@numeri,0 )} elsif ($aa=~/^child$/){$cond[1]='child'; push(@numeri,1 )} elsif ($aa=~/^free$/) {$cond[2]='free'; push(@numeri, 2)} elsif ($aa=~/^love$/) {$cond[3]='love'; push(@numeri, 3)} elsif ($aa=~/^enjoy$/) {$cond[4]='enjoy'; push(@numeri, 4)} else {print "\n\n$aa wrong argoument!!! I proceed with @cond\n\n"} } #the possible returned array from a sub @car=qw(peace child free love enjoy); print "\n\ncar=@car\ncond=@cond\nnums=@numeri\n\n\n"; ##############here suggestion please################### $bol=1; foreach $num(@numeri) { last if ($bol==undef); if ($car[$num]eq$cond[$num]){$bol=1}else{$bol=undef} } if (defined $bol){print"boleano=$bol FOUND!"} else{print "NOT found!"}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: terrible code about array matching...
by chromatic (Archbishop) on Nov 06, 2002 at 07:19 UTC | |
|
Re: terrible code about array matching...
by grantm (Parson) on Nov 06, 2002 at 07:43 UTC | |
by davorg (Chancellor) on Nov 06, 2002 at 10:50 UTC | |
by grantm (Parson) on Nov 06, 2002 at 20:52 UTC | |
by Discipulus (Canon) on Nov 06, 2002 at 08:51 UTC | |
|
Re: terrible code about array matching...
by fruiture (Curate) on Nov 06, 2002 at 14:14 UTC | |
|
Re: terrible code about array matching...
by jlongino (Parson) on Nov 06, 2002 at 15:38 UTC |