Hi All,
I new in Perl CGI. Now I am facing a problem when I fetch my username and password from previous page to existing page, my form data will be not function. Form Data only function when the script is on the top and same to scalar it also only function if the script is on the top of the page. Script as below:

#!/usr/bin/perl

use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use CGI::Pretty qw(:all);

my $username = param('username');
my $password = param('password');


read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
$buffer =~ tr/+/ /;
$buffer =~ s/\r/ /g;
$buffer =~ s/\n/ /g;
@pairs = split(/&/,$buffer);
foreach $pair(@pairs){
($key,$value)=split(/=/,$pair);
$formdata{$key}.="$value";
}
#delete file
$version=$formdata{'version'};
$Chassis=$formdata{'Chassis'};
$Assigned=$formdata{'Assigned'};.....