Greetings,
Here is my question. In the below code I have the user enter in a part number and
revision. These are then written into a text file. All this works as it should. The
next step that I want to get to is this. When the user enters the part number and
revision I would like the script to first look at the text file and see if the number
already exists. If it does, I then want any information that follows that number to be
outputted to the screen. If the number does not exist then I want the script to write
it to the text file. I hope this is clear. When it outtputs to the screen I need a way
to tell it what part of the text file to actually print. I do not want the whole file
to print.
So in a nutshell, how can I have it look at the text file for the part number and then
print out the information.
I know that the code does not look pretty, but I am learning. I will eventually learn
to format it more properly. Thank you for your help.
print "What is the Part Number that you would like to look up?\n";
my $PartNumber = <STDIN>;
chomp($PartNumber);
while (!$PartNumber){ ## while $PartNumber is empty keep asking
print "PartNumber? ";
$PartNumber = <STDIN>;
chomp($PartNumber);
}
print "What is the Revision level for $PartNumber?\n";
my $Revision = <STDIN>;
chomp($Revision);
while (!$Revision){ ## while $Revision is empty keep asking
print "Revision? ";
$Revision = <STDIN>;
chomp($Revision);
}
open(FILE, '>>fai.txt') || die $!;
printf FILE "\t$PartNumber Rev. $Revision\t";
close(FILE);
print "$PartNumber Rev. $Revision has a First Article Report\nWould you like to view
it?";
my $answer = <STDIN>;
chomp($answer);
# If the answer is yes then fill the form with the information
if ($answer eq "yes") {
print "\n\n\none second please......\n\n\n\n\n";
print "retrieving file........\n\n\n\n\n";
}
# If the answer is no then die
else {
print "ok, well have a nice day.\n\n\n\n\n";
}
Kerry LeBlanc
Materials Auditor
Process Owner
75 Perseverence Way
Hyannis, MA. 02601
1-508-862-3082
http://www.vsf.cape.com/~bismark <http://www.vsf.cape.com/~bismark>