#!/usr/bin/perl use diagnostics; use URI; my $uri = URI->new("-invalid-input-harhar-")->canonical; my $host = $uri->host;