A list in Perl is pretty much like an array although there are some fine differences between these two concepts. I think your nomenclature {} vs () and description may not be the best. The {} does not describe an array or a "list".

An "exit code" says to me that this is single integer value from returned to the O/S, not a multi-valued thing or data structure - an "exit code" is an integer in Windows or Unix.

I think you mean to check the return array value from a subroutine? This code checks that the main program only got one returned value and that that single value is "3".

#!usr/bin/perl -w use strict; my @result; @result = X(); print "array returned from sub X is: ", @result,"\n"; if ((@result == 1) and ( grep {$_ == 3}@result )) { print "Sub X passes the test", @result,"\n"; } else { print "@result: for Sub X fails the test\n"; } print "\n"; @result = Y(); print "array returned from Sub Y is: ", @result,"\n"; if ((@result == 1) and ( grep {$_ == 3}@result)) { print "Sub Y @result passes the test\n"; } else { print "Sub Y @result fails the test\n"; } print "\n"; sub X { return (1,2,3,4,5,6,7,8,9); } sub Y { return (3); } __END__ array returned from sub X is: 123456789 1 2 3 4 5 6 7 8 9: for Sub X fails the test array returned from Sub Y is: 3 Sub Y 3 passes the test
Update: well if the OP's intention is that should work for anything but 3, then the modifications should be obvious.

In reply to Re: Do not run code even if one element has matched exit code value by Marshall
in thread Do not run code even if one element has matched exit code value by jayu_rao

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.