link-checker commit: Avoid "uninitialized $hostport" warnings, generated with e.g. news: URIs.

changeset:   403:81914ff50f48
tag:         tip
user:        Ville Skyttä <ville.skytta@iki.fi>
date:        Fri Apr 29 22:42:40 2011 +0300
files:       bin/checklink
description:
Avoid "uninitialized $hostport" warnings, generated with e.g. news: URIs.


diff -r f715518f132e -r 81914ff50f48 bin/checklink
--- a/bin/checklink	Sat Apr 02 20:53:13 2011 +0300
+++ b/bin/checklink	Fri Apr 29 22:42:40 2011 +0300
@@ -1235,9 +1235,10 @@
         my $fragment  = $canon_uri->fragment(undef);
         if (!defined($Opts{Exclude}) || $canon_uri !~ $Opts{Exclude}) {
             if (!exists($links{$canon_uri})) {
-                my $hostport =
-                    $canon_uri->can('host_port') ? $canon_uri->host_port() :
-                                                   '';
+                my $hostport;
+                $hostport = $canon_uri->host_port()
+                    if $canon_uri->can('host_port');
+                $hostport = '' unless defined $hostport;
                 push(@{$hostlinks{$hostport}}, $canon_uri);
             }
             for my $line_num (keys(%$lines)) {

Received on Friday, 29 April 2011 19:42:57 UTC