hello, im a learner in PERL and have to create a perl program.
when run the user is prompted for a 4 digit cust ref no, then
title, surname, forename, sex, DOB, vision measurement.
all these nee to be verified, if any fails an error message has to appear, then prompted to re-enter info. the verification is
cust no - 4 digitd
title - 1-4 alpha charc, and allow titles, Dr, Lady, Lord, Miss, Mr, Mrs, Ms, Sir
Surname - 1-20 alpha charc
Forename - 1-20 alpha charc
Sex - 1 charc, either m or f ( upper or lower)
DOB - in dd/mm/yyyy
vision - 1-2 digits ( between 1-99
i have created some code for this but keep getting errors, don't know why?? Could anyone please tell me what ive got wrong in this code?
print ("Please enter your customer ref number:\n");
$Custref = <STDIN>;
chomp ($Custref);
while ($Custref !~m/^[0-9]{4}$/)
{
print ("Sorry Please try again:\n");
$Custref = <STDIN>;
chomp ($Custref);
}
!!!!!while bits (instead of writing it all out!!!!!
Title while ($Title !~m/^[Dr|Lady|Lord|Miss|Mr|Mrs|Ms|Sir]{0-4}$/)
Surname while ($Sur !~m/^[a-zA-Z]{0-20}$/)
Forename while ($Fore !~m/^[a-zA-Z]{0-20}$/)
Sex while ($Sex !~m/^[m-M|f-F]{1}$/)
DOB while ($Dob !~m/^[0-9999] not sure how to make it valid for
DD/MM/YYYY
Vision while ($Vision !~m/^[1-99]{1-2}$/)
I just keep going round in circles, so any help will be much appreciated
karen![]()



Reply With Quote

Bookmarks