Hi,

I want to print the last entry by record "1111" in this file "records.txt"
The file is read in a subroutine and prints last line by the number in this
example.


# records.txt
1111 25.11.2009 NAME_0
2222 15.12.2006 NAME_3
3333 20.10.2007 NAME_1
1111 01.01.2008 NAME_3    <-- This whole line should be printed.
4444 10.10.2008 NAME_4

Using while in a while loop matching ( m/1111/ ) I get all the entries
having "1111".


sub who_is_who($) {

    open( FILE_DB, '<', "INFODB.TXT") || die "Cannot open INFODB.TXT\n";
    my $number = $_[0]; # print "\$number is $_[0]\n";

    while ( <FILE_DB> ) {
        while ( m/^$number\s+(\S+)\s+(.*)$/mgs ) {   # <-- tried "while" as
well as "if"
            &get_info($match, $1, $2);
            # if (! $1) { die "\nNo Entries Found for $match\n\n" };
        }
    }
    close(FILE_DB);
}

How can I do this?

Reply via email to