in reply to How to get a value from a file and save in another file

Still not clear what you mean by "first record", is "LA-03-2" and "LA-03-2" considered the same because the middle number "03" being the same, or the two numbers are numerically the same? Assuming the first:
use strict; my %seen; while(<DATA>){ chomp; my @parts = split /-/; print $_,"\n" if $parts[0] eq 'LA' && !$seen{$parts[0]-$parts[1]}+ ++; } __DATA__ LA-1-00 CON-1-0 LA-2-01 LA-03-2 LA-03-02

Replies are listed 'Best First'.
Re^2: How to get a value from a file and save in another file
by Anonymous Monk on Apr 27, 2005 at 18:55 UTC
    I am sorry for the miss leading the data I used. Let me try it again:
    The data file is:
    Record1: CON-aaa
    -----------LA-bbbbb
    -----------LA-aaaaa
    Record2: LA-12345
    -----------LA-1ad1d
    ...
    I want to output the first data with "LA" in record 1, record2 and so on. The result should be like:
    LA-bbbbb
    LA-12345
    There is no need to check if the rest of the value after the "LA-".

    Thank you again!!