Compare values in array

terrylau's Avatar, Join Date: Jul 2009
Go4Expert Member
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.
shency's Avatar, Join Date: Oct 2008
Go4Expert Member
Two dimensional would be better!