http://www.perlmonks.org?node_id=996330


in reply to Custom error messages and moose

You could always put in a test like
my $ip_address = ""; if ( $allclasses_file =~ m/_([^_]+$)/ ) { $ip_address = $1; unless ($ip_address =~ m/\d+\.\d+\.\d+\.\d+/) { print "Bad ip value $ip_address\n"; } } return $ip_address;
or just change your code to use the '\d+\.\d+\.\d+\.\d+' like this
my $ip_address = ""; if ( $allclasses_file =~ m/_(\d+\.\d+\.\d+\.\d+)$/) { $ip_address = $1; } return $ip_address;