Read each line, extract the value you are interested it and store it in a hash (as the key of the hash, the value can be anything, for example "1"). This will remove duplicates, because there cannot be duplicate keys in a hash. Then just print the keys of the hash.

Thanks Laurent. Can you suggest me how to get the substring? I mean, I was thinking to use substr function, but I should pass a specific offset and lenght. Is it right? Or should I use some other function?

Bareword found where operator expected at ./BatchParser.pl line 17, near "#if ( $FileTemp" (Might be a runaway multi-line $$ string starting on line 16) (Missing operator before FileTemp?) syntax error at ./BatchParser.pl line 16, near "\." syntax error at ./BatchParser.pl line 22, near "}" Execution of ./BatchParser.pl aborted due to compilation errors.

I'm try to extract the value after field "TRANSID,". I separate all the line after ":", in tris way I have a line with "TRANSID," and its value. These lines are in variable $FileTemp. Then I'd like to extract just the value in these lines and store them in variable $value1.

TRANSID si what in my first post is called FieldCostant2. I try to extract the value in case TRANSID is not in a fix position (for example in one of FieldCostantx). I hope to explain my point.