Compare values in array

Discussion in 'Perl' started by terrylau, Aug 11, 2009.

  1. terrylau

    terrylau New Member

    Joined:
    Jul 2, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    row0 device1, device2, device3, device4, device5, device_label
    row1 0000, 0000, 0000, 0000, 0000, 00A1
    row2 0000, 2222, 0000, 1111, 0000, 00A2
    row3 0000, 0000, 0000, 0000, 0000, 00A3
    row4 0000, 0000, 0000, 0000, 0000, 00A1
    row5 0000, 0000, 0000, 3333, 0000, 00A2
    row6 0000, 0000, 0000, 0000, 0000, 00A3

    Hi am a Perl newbie here... Need a Perl script to do this.

    1. Scan all the fields from top to bottom and load into array. (Done)
    2. Select the lines with the device_label 00A2 only.
    3. Compare all the values within the lines, and select those with the different value from the majority value (in this case is 0000, could be other values).
    4. Print out which fields that has the different value from the majority. In this case the output should be row2 device2, row2 device4 and row5 device4.

    Which is better? Load all the values into a single array or a two-dimensional array for easier comparison?

    I've managed to do step 1 but stuck on proceeding to the rest. Would appreciate advice and guidance here.
     
  2. shency

    shency New Member

    Joined:
    Oct 25, 2008
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Two dimensional would be better!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice