The following code apparently is not doing what I wanted. My intention was to 
confirm that the general format of  $student_id was this: several uppercase 
letters followed by a hyphen followed by several digits. If not, it would 
trigger the die. Unfortunately it seems to always trigger the die. For example, 
if I let student_id = triplett-1, the script dies. I’m a beginner, so I often 
have trouble seeing the “obvious.” Any suggestions will be appreciated!

        if      ( $student_id =~
                        /
                                (\A[a-z]+)              # match and capture 
leading alphabetics 
                                -                               # hyphen to 
separate surname from number
                                ([0-9]+\z)              # match and capture 
trailing digits
                        /xms                            # Perl Best Practices
                ) {
                        $student_surname = $1;
                        $student_number  = $2;
        }
        else {
                die "Bad general form for student_id: $student_id"
        };


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to