as part of my assignment i'm trying to validate an email address stored in an hash, with the key: 'email' and the value as the data supplied. But the email is not getting validated using reg-ex:

if($form_element{'email'} =~ m/^[A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{2,4}$/i){
        $values = 0;
        $mail = "InValid!";
} else {
        $mail = "Valid!";
}
if($form_element{'email'} =~ m/^[a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-]+([.][a-zA-Z0-9_\-]+)+[a-zA-Z]{2,4}$/i){
        $values = 0;
        $mail = "Valid!";
} else {
        $mail = "InValid!";
}
commented: Excellently answered!! +1

lol!! thanks alot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.