hello Momks!

I'm still newbing around perl coding, suggest me something about the following problem and dont let me publish my neanderthal code..
SITUATION:I have a sub that return an array.The user put some parameters in @ARGV.
GOAL:I want verify that all argv input match with the first array before print it(but only if ALL match).

My first attempt was to give a big argoument to a if cicle but it was a flop.can I put a foreach cicle into a if condition?
My neanderthal code runs but it is terrible to my newbies eyes too.. plz suggestion..
foreach $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!"}
greetings freom sunny roma
lor*

In reply to terrible code about array matching... by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.