in reply to Validating Comma Delimited String
More of a problem, however, is your use of a range ([...]) c/w a block/capture ((...)). Try ...
Givesperl -we '$string = qq/9500,9501,fred,,9999/; map { warn qq/Bad entry: + $_ in string $string/ } grep ! /^\d{4}$/, split /,/, $string;'
Bad entry: fred in string 9500,9501,fred,,9999 at -e line 1. Bad entry: in string 9500,9501,fred,,9999 at -e line 1.
|
|---|