Building From Parts

my $scheme   = qr{(http|https|ftp)://};
my $login    = qr{([^/]*?:[^/]*?@)};
my $hostname = qr{([^/]*?)};
my $pathname = qr{(/[^?#]*?)};
my $querystr = qr{(\?[^#]*?)};
my $fragment = qr{(\#.*)};

if(/^$scheme$login?$hostname$pathname$querystr?$fragment?$/) {
  # Do stuff
}