until($cust =~ <\w{3,4}>) {
You should get your expected behavior by changing that to:
until($cust =~ /\w{3,4}/) {
since you are trying to match against a regular expression. I'd also add start and end anchors, as your expression as written would also match a 17-letter expression - it contains multiple 3 and 4 letter sets.
until($cust =~ /^\w{3,4}$/) {
As a side note, you can use last to do flow control and reduce your code repetition, as well as use a heredoc:
use strict; use warnings; while (1) { print "Customer abbreviation: "; my $cust = <STDIN>; print "\n"; chomp ($cust); last if $cust =~ /\w{3,4}/; print <<EOT; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! !!! !!! ABBREVIATION MUST BE 3 OR 4 CHARACTERS !!! !!! !!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! EOT }
In reply to Re: problem with pattern match
by kennethk
in thread problem with pattern match
by ddrew78
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |