Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Quiz of the Week :: Perl

Options
  • 07-05-2001 11:16am
    #1
    Closed Accounts Posts: 33


    An easy one to start off with...

    Say I inserted this into a Perl file:
    $phone = "(123) 456-7899";
    
    if ($phone =~ /^(\(\d\d\d\))? ?\d\d\d-\d\d\d\d$/) {
    	print "$phone";
    } else {
    	print "Please enter your phone number again.";
    }
    

    What would it do/output *or* whats wrong with it? No cheating by executing the script on the web or anything.

    [This message has been edited by Robbie Burke (edited 07-05-2001).]


Comments

  • Closed Accounts Posts: 1,819 ✭✭✭K!LL!@N


    I don't know anything about Perl.
    But from the look of it, i'd say it checks that the phone number entered conforms to the correct structure. If it does then it prints out the number. If not it prints out the message " Please enter your phone number again.".


  • Closed Accounts Posts: 33 Robbie Burke


    Told ya'll it was easy, solved in less than an hour and by someone with no knowledge of perl...well doen K!LL!@N

    [This message has been edited by Robbie Burke (edited 07-05-2001).]


  • Closed Accounts Posts: 1,819 ✭✭✭K!LL!@N


    biggrin.gif


Advertisement