Need help to modify perl script: Text file with line and more than 1 space

Dear Friends,
I am beginner in Perl and trying to find the problem in a script. Kindly help me to modify the script. My script is not giving the output for the last field and followed text (LA: Language English). Input file & script as follows:

Input file:

Thu Mar 19 2:34:14 EDT 2009
STC
Data query:

Record 1 of 1

DN: Data Name
Information Sciences
TI: Title
Distribution and abundance of bound volumes of the file in institute
shelves from 1978
AU: Author
Sahu, SR; Gawas, AKG
AF: Affiliation
Inst. of document scanning and documentation profiling at library,
toward the prograssive society and establishment
SO: Source
Test document file. Vol. 5, no. 1, pp. 1-14. Jul 1990.
DE: Descriptors
Article Subject Terms: Abundance; Ecological distribution;
Geographical distribution; Life cycle; Zooplankton; Article Taxonomic
Terms: Euphausia; Article Geographic Terms: ISW,
LA: Language
English

Perl Script:

#!/usr/bin/perl -w

my $found_f = 0;
my ($lastline, $line);
open (INPUTFILE, "test.txt");

while (<INPUTFILE>)
{
chomp;

if (/^[A-Z]{2}:\s/) {
$lastline = $line;
$line = $;
$found_f = 1;
}
elsif (! /^[A-Z]{2}:\s/ && $found_f) {
s/^ {4}/ /;
$line .= $
;
next;
}
elsif (/^$/) {
$lastline = ' ';
$found_f =0;
}
print "$lastline\n";

Kindly help me in modifying the script to proceed further

You have

Loop
    If matches 2 characters followed by a colon
        Set lastline to line
        Set line to input from file
    If doesn't match 2 characters followed by a colon
        Append input from file to line
End Loop
Print lastline

You can clearly see from this that lastline is only computed on a 2 character/colon line, so the last input line will always be missed as it's not a 2 character/colon line.

Kindly let me know, "what I should do to get the desired result?"

What happened to the post on perlguru? Didn't like that suggestion?

Sorry for not debugging your code but I found it much easier to rewrite it:

use strict; 
use warnings; 
open (INPUTFILE, "test.txt");  
MAIN: while (<INPUTFILE>){  
   chomp;  
   if (/^[A-Z]{2}:\s/) { 
      my $line = $_; 
      while (<INPUTFILE>) { 
         chomp; 
         if (/^[A-Z]{2}:\s/ or eof) { 
            print $line,"\n"; 
            redo MAIN  
         } 
         $line .= $_; 
      } 
   } 
}