Results 1 to 6 of 6

Thread: Help!! learner in Perl

  1. #1
    Join Date
    May 2006
    Location
    Birtley, near newcastle UK
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help!! learner in Perl

    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

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well why don't you give us the errors?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Location
    Birtley, near newcastle UK
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default sos

    sorry

    when i run just the " enter ref number with the while bit
    it comes up with:

    syntax error at cust.pl line7, near ");"
    execution of cust.pl aborted due to compilation errors.

    this should work as far i can see!!!!

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Which line is 7?
    Paste your whole script here. In [code] tags, please.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    May 2006
    Location
    Birtley, near newcastle UK
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hiya

    got some of the code working, (finaly)
    i can't seem to copy my script from perl into anything for some reason!!!
    why is this???

    Does anyone actually still use perl as ive asked in the web dept at work an they say they've never used it!!!!

    the only problem ive got now is how to verify the date so it only accepts
    DD/MM/YYYY not sure how to get it to include the backslashes!!!

    does anyone know a good place to get info on perl as ive had a look but a lot of it doesnt go into much detail.

    much appreciated

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Does anyone actually still use perl as ive asked in the web dept at work an they say they've never used it!!!!
    I'd say that they were inexperienced and incompetent, then. I've probably just offended half of them, but I don't really care Perl is still used commonly in many roles, of which CGI is one. In fact, it's probably the most popular CGI language out there, if we ignore PHP which can be run as a CGI parser to work around webserver or permissions problems.
    does anyone know a good place to get info on perl as ive had a look but a lot of it doesnt go into much detail.
    The perldoc(1) utility and the standard files for it that come with Perl are an excellent reference.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •