[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Database Program..



Hi!

I have a small program to access database file.  It works fine
other then when I type in 'q' in the prompt, the program does
not quit.  Can anyone suggest how do I get about it.  Here is
the programme.

#!/usr/bin/perl -w

$TheDB='edata.txt';
open(INDB,$TheDB) or die "The database $TheDB cound not be found.\n";
while (1) {
print "\nDo you want to search by employee ID(I) or quit(Q):";
$DoSearch = <STDIN>;
chomp ($DoSearch);
$DoSearch=~tr/A-Z/a-z/;
if (DoSearch eq 'q') { last }
unless ($DoSearch eq 'i'){
print "You must enter either I or Q.\n";
next;
}
print "Search for ID number:";
$SearchFor=<STDIN>;
chomp ($SearchFor);
seek (INDB,0,0);
$SuccessCount=0;
while(<INDB>){
$TheRec=$_;
chomp ($TheRec);
($LastName,$FirstName,$ID,$Tel)=split (/\t/, $TheRec);
if ($ID eq $SearchFor){
$SuccessCount=$SuccessCount + 1;
print "$ID: $FirstName, $LastName, ext.$Tel\n";
}
}
if ($SuccessCount==0){ print "No records found.\n"}
else{print "$SuccessCount records found.\n"}
}
print "Programme finished.\n";


thanks in advance
Amitava Basu


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch