I'm not sure if this is the place, so correct me if I'm wrong. I'm
just guessing this mailing list is more frequently read by those I
think are involved, so apologizes if this isn't the place..

I tried using Data::Validate::Domain (specifically exporting the
function is_domain) and obviously (to me, obviously, that is) using
the (relatively newly discovered for me) module IO::Prompt.

Thing is, it didn't work.
Here is a simple example:
while (!is_domain($site_name)) {
        # debugging
        print "site_name: $site_name\n";
        $site_name = prompt('Please enter a valid hostname: ');
        # debugging
        print "site_name: $site_name\n";
}

For some reason it always failed.
As you can see, I've added two lines to check what's wrong with the value.
I tried different things, till I decided to check it with Data::Dumper.
Low and behold, it returns an object. Here is the output:
site_name: $VAR1 = bless( {
                 'success' => 1,
                 'handled' => 1,
                 'set_val' => 0,
                 'value' => 'hello.com',
                 'context' => 27
               }, 'IO::Prompt::ReturnVal' );

Obviously if I would remember TFM after RTFM I would know this by heart.

Still, maybe there should be a method, or parameter (IO::Prompt
already uses a lot of those) that indicates it shouldn't return an
object, but a simple string?
Right now I changed the code to:
while (!is_domain($site_name)) {
        $site_name = prompt('Please enter a valid hostname: ')->{value};
}
and it works perfectly.

Reply via email to