Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: terrible code about array matching...

by Discipulus (Canon)
on Nov 06, 2002 at 08:51 UTC ( [id://210690]=note: print w/replies, xml ) Need Help??


in reply to Re: terrible code about array matching...
in thread terrible code about array matching...

ok maybe i have english level difficulties.. ;)
thnks for the remark about matching vs eq
foreach $aa (@ARGV) { if ($aa eq 'peace'){$cond[0]='peace'; push(@numeri,0 )} elsif ($aa eq 'child'){$cond[1]='child'; push(@numeri,1 )} elsif ($aa eq 'free') {$cond[2]='free'; push(@numeri, 2)} elsif ($aa eq 'love') {$cond[3]='love'; push(@numeri, 3)} elsif ($aa eq) {$cond[4]='enjoy'; push(@numeri, 4)} else {print "\n\n$aa wrong argoument!!! I proceed with @cond\n\n"} } #the possible returned arrays from a sub @car=qw(peace child free love enjoy); #1 #or @car=qw(war child -- love enjoy); #2 #or @car=qw(peace song freedom -- xx); #3 ##############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!"}
Example of what I wont:
you put as INPUT: peace
ok for the first @car
wrong for the second
ok for the third

you put as INPUT: peace love
ok for the first occuourence of @car
wrong for the second and third occourence

In this way,when I receive 5 times @car, I want print it ONLY if all the option insered in @argv match with the courrent array.
many thanks
lor*

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://210690]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found