vendredi 27 juillet 2018

Perl: Comparing two lines at once while reading in a file

I have a perl script that reads text file line by line and splits the line into different columns. It randomly generates hex colors for each distinct number before the decimal point (format: $cols[2].$cols[3] #random_hex_color). The number after the decimal is not considered. I am trying to compare $cols[2] for line X with $cols[2] for the next line. If the numbers are equal, the #random_hex_color should be the same.

So far, I am randomly generating a new #random_hex_color for every line.

Desired output: 22.1 #9139491 66.3 #D465671 66.5 #D465671 31.8 #C18D961




Aucun commentaire:

Enregistrer un commentaire