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

Thank you for the help. I want to print out the first value that start with "LA-" for each record. In my example file there are 3 records and each record has 1 or 2 or more values. In my real file there Hundreds records.
  • Comment on Re^2: How to get a value from a file and save in another file

Replies are listed 'Best First'.
Re^3: How to get a value from a file and save in another file
by ikegami (Patriarch) on Apr 27, 2005 at 18:13 UTC
    use strict; use warnings; my $found_match = 0; while (<DATA>) { s/\s+$//; if (/^\d/) { $found_match = 0; } if (!$found_match && /^\d*\s+(LA.*)/) { print("$1\n"); $found_match = 1; } } __DATA__ 1 LA-1-00 2 CON-1-0 LA-2-01 3 LA-03-2 LA-03-02