($ldhost = $self->qp->config('ldap_host')) =~ qr/^(([a-z0-9]+\.?)+)$/; $ldhost = "localhost" unless ($ldhost);
Work similarly, without requiring a special sub?
Actually, that is nice and compact. My suggestion for adding it to config() was to encourage module authors to think seriously about what they are doing. I was hoping to prevent slack tests like this:
plugins/rcpt_ok- for my $allowed (@rcpt_hosts) {
plugins/rcpt_ok: $allowed =~ s/^\s*(\S+)/$1/;Yes, I wrote that module, why do you ask? :0
Making it easy to use and documenting it makes it more likely that it would be used effectively.
I like your idea of predefined regexp to match the bulk of the likely input values, but I wonder if just using Regexp::Common might be easier than brewing our own (see the example in Chapter 5 of /Mastering Regular Expressions/ for performing a IP address test). Looking at the current collection of plugins, the following would need to be covered:
FQDN
IP
FILENAME or PATH
INTEGER or NUMBER
STRING of CHARACTERThe remaining capture replacements seem to be mostly stripping certain bits out of output captured from an external program and don't have any bearing on this discussion...
John
