in reply to Recognizing numbers

Hello htmanning,

I'm trying to recognize numbers in a variable and return an error if a number is detected. For example, there is no reason to have a number in the "name" field.

I think this approach is, potentially, a maintenance nightmare in the making. Coming back to the code in, say, 6 months time: Did you mean to allow semicolons, commas, tab characters? To exclude the West Arabic (Latin alphabet) digits 1, 2, 3, ..., but allow their East Arabic equivalents ٢, ٣, ١, ...? If it’s at all possible, it will be much better to specify explicitly what a “name” is allowed to contain:

my $name_re = qr/^[- A-Za-z]+$/; ... unless ($name =~ $name_re) { warn "Bad name '$name'"; ... }

Then if, down the track, you find that additional characters are needed (e.g., should underscores be allowed?), they can be added once to $name_re, and the code remains clear and self-documenting.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,