in reply to PLEADE HELP ME!![NEWBIE]

This works for me:
@aray = ( '1, 2, 5, 1, 2, 5, 1, 2, 5', '3, 6, 3, 6, 3, 6, 3, 6', '4, 1, 28, 0, 4, 1, 28, 0', '3, 5, 17, 3, 17, 5', '4, 1, 28, 0, 4, 1, 28', ); for ($i = 0; $i < @aray; $i++) { if ($aray[$i] eq '1, 2, 5, 1, 2, 5, 1, 2, 5') { print 3 } if ($aray[$i] eq '3, 6, 3, 6, 3, 6, 3, 6') { print 4 } if ($aray[$i] eq '4, 1, 28, 0, 4, 1, 28, 0') { print 2 } if ($aray[$i] eq '3, 5, 17, 3, 17, 5') { print 0 } if ($aray[$i] eq '4, 1, 28, 0, 4, 1, 28') { print 0 } }

Replies are listed 'Best First'.
Re^2: PLEADE HELP ME!![NEWBIE]
by ikegami (Patriarch) on Dec 20, 2011 at 21:11 UTC

    yuck!

    • "Array" is misspelled.
    • "Array" is a poor name for variable.
    • Needless comparisons are being done. At a minimum, use elsif, but a lookup table would be better!
    • C-style for loop is needlessly complex.
    • No line breaks output.
      • misspelled but consistent ... no undeclared variable were used (besides, did you see the OP?)
      • poor, but it works
      • again, it works
      • complex, but it works
      • there will be line breaks if you populate $/ with a newline
      • you really take yourself much too seriously (this was a joke dude!)

        you really take yourself much too seriously

        I played along rather than suggest you use a sensible algorithm, so that's obviously false.

        poor, but it works. again, it works. complex, but it works

        Are those addressed to me? I said the code was awful, not that it didn't work (except for the badly formatted output).