Assistance in Perl scripting

PFA file "color.txt".
Note : There is no newline character in the file. I have manually inserted the newline char to make it easy to understand.

I am expecting out in the form as specified in second file "out.txt"

I need a perl script to perform the task.

Thanks in advance.

Kaustubh

Can you elaborate more?

How are going to run this script? Is 'color.txt' the input file?

Regards
Abhi

yes..its gonna be an input file inside my main script.