The only problem I can see is that you want UPPERCASE-1234 and your regex has lowercase. Try
(\A[A-Z]+) # match and capture leading alphabetics Andrew p.s Why not add "use strict; use warnings", "my $var;" and wear a seat belt when you're driving?:) On Wed, Nov 25, 2015 at 5:09 PM, Rick T <p...@reason.net> wrote: > 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/ > > > -- Andrew Solomon Mentor@Geekuni http://geekuni.com/ http://www.linkedin.com/in/asolomon