I'm not entirely clear, but if you are asking about how to read file line by line
open(KFILE, "<", "kfile.txt" ) or die "Can't open kfile: $!\n";
while ( defined($krec = <KFILE>) )
# Here you do stuff with the rec;
# Note that your recs seem to sometimes have space separated fields, sometimes ';' separators
close(KFILE) or die "Can't close kfile: $!\n";
Obviously you rename the vars etc, but you get the idea.
Also, I'd avoid having scalars and arrays having effectively the same name, even if they are in separate name-spaces; it becomes prone to difficult to find typos as the code gets longer.
To get separate "fields" from your recs (if you need to), use http://perldoc.perl.org/functions/split.html
HTH - come back if you need more