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

Quick perl/regex question

Options
  • 30-03-2008 2:33pm
    #1
    Closed Accounts Posts: 2,349 ✭✭✭


    Getopt::Long::GetOptions ("username|u=s" => \$username, "password|p=s" => \$password, [EMAIL="'recipients|recipient|r=s@{1,}'"]'recipients|recipient|r=s@{1,}'[/EMAIL] => \@recipients, "message|m=s" => \$message, "debug|d!"     => \$debug, "dump|dd!" => \$dump);
    
        chomp($username);
        print $username;
        if ($username !~ m/^[0-9*]$/) {
          print STDERR "Username \"$username\" must contain only numbers\n";
          exit;
        }
    
     
    

    Hi, quick perl question, I'm trying to make sure a command line argument $username contains only numbers. I take it in via GetOptions and do the match above.

    It prints the error message every single time. print $username outputs "123456789" with no newline character after it.


Comments

Advertisement