in reply to Re: Checking name convention
in thread Checking name convention

Because no  $ end-of-string anchor is used, the  /^[A-Za-z]{3}\d{3}/ match may allow something improper:

c:\@Work\Perl\monks>perl -wMstrict -le "my $os_user = 'foo9876543210'; $os_user =~ /^[A-Za-z]{3}\d{3}/ or die qq{bad user name: '$os_user'}; print qq{'$os_user' is ok by me!}; " 'foo9876543210' is ok by me!
See above for a variation that avoids this problem. See also perlre, perlrequick, and perlretut.


Give a man a fish:  <%-(-(-(-<

Replies are listed 'Best First'.
Re^3: Checking name convention
by Stringer (Acolyte) on Feb 24, 2015 at 20:22 UTC
    Woops, you're right. Updated it with the requisite anchor.