print "What is the Part Number that you would like to look up?\n"; my $PartNumber = ; chomp($PartNumber); while (!$PartNumber){ ## while $PartNumber is empty keep asking print "PartNumber? "; $PartNumber = ; chomp($PartNumber); } &search; #this is the subroutine to search the file sub search{ open(FILE, '>>fai.txt') || die $!; while () { chomp; # remove newline my @fields = split(/\|/, $_); # test whether the search string matches part number if ($fields[0] =~ /$PartNumber/ ) { print "$PartNumber Rev. $Revision has a First Article Report\nWould you like to view it?"; } }} close(FILE); my $answer = ; chomp($answer); if ($answer eq "yes") { print "\n\n\none second please......\n"; print "retrieving file........\n"; error caused by this--> print "$fields[0]: $fields[1]: $fields[2]: $fields[3]\n"; } # If the answer is no then die else { print "ok, well have a nice day.\n"; }