That did the trick. I was missing
$ua->requests_redirectable ([]);
Thank you!

I do read the docs. I just don't understand what I am seeing, which I why I appreciate your help. (You will notice that I include my references in my code's comments)

#!/usr/bin/perl use strict; use warnings; #use diagnostics; #use diagnostics "-verbose"; use constant MaxTime1 => 20; # Seconds use LWP::UserAgent; use Term::ANSIColor qw ( BOLD BLUE RED GREEN RESET ); my $Debug = "yes"; my $RedirectUrl; my $IAm = "UrlRedirectTest.pl "; my $WebSite; sub GetUrlRedirect ( $$ ) { # Return $Url's redirected web page. Black string if none if locat +ed # References: # http://stackoverflow.com/questions/26087546/perl-print-the-redi +rected-url # http://search.cpan.org/~ether/libwww-perl-6.15/lib/LWP/UserAgen +t.pm # http://stackoverflow.com/questions/2470053/how-can-i-get-the-ul +timate-url-without-fetching-the-pages-using-perl-and-lwp # https://metacpan.org/pod/HTTP%3A%3AResponse # $r->redirects # Returns the list of redirect responses that lead up to this + response # by following the $r->previous chain. The list order is olde +st first. # In scalar context return the number of redirect responses l +eading up # to this one. # # system ('curl -s "SomeUrl" -w %{redirect_url}'); my $IAm = ( caller(0) )[3]; # Incoming: my $Url = $_[0]; my $Caller = "$_[1]" . "$IAm"; # supposting variables my $ua; my $res; # my $redirect; # my $NewUrl; $ua = LWP::UserAgent->new; $ua->timeout ( MaxTime1 ); $ua->show_progress; $ua->requests_redirectable ([]); $res = $ua->get($Url); # The parentheses around $redirect tell Perl that you want $redirec +t # to be seen as list as you in fact are only interested in the firs +t redirec if ($res->is_redirect) { my ( $NewUrl ) = $res->header('Location'); # my $NewUrl = ( $res->header('Location') ) [1]; if ( "$Debug" eq "yes" ) { print STDERR "Redirect Url = <${NewUrl}>\n"; } return ${NewUrl}; } else { print STDERR "${Caller}: ${Url} has no redirect\n"; return ""; } } $WebSite = 'http://gbis.com'; $RedirectUrl = GetUrlRedirect ( $WebSite, $IAm ); print "WebSite <$WebSite> redirects to <$RedirectUrl>\n\n"; $WebSite = 'http://google.com'; $RedirectUrl = GetUrlRedirect ( $WebSite, $IAm ); print "WebSite <$WebSite> redirects to <$RedirectUrl>\n\n"; $WebSite = 'http://usa.kaspersky.com/files/?file=kis&program=one&lang= +en&track=pu_kiskis_usen'; $RedirectUrl = GetUrlRedirect ( $WebSite, $IAm ); print "WebSite <$WebSite> redirects to <$RedirectUrl>\n\n"; END $ ./Url.Redirest.Test.pl UrlRedirectTest.pl main::GetUrlRedirect: http://gbis.com has no redire +ct WebSite <http://gbis.com> redirects to <> Redirect Url = <http://www.google.com/> WebSite <http://google.com> redirects to <http://www.google.com/> Redirect Url = <https://klamericas.s3.amazonaws.com/files/one/en/kis17 +.0.0.611en_10755.exe> WebSite <http://usa.kaspersky.com/files/?file=kis&program=one&lang=en& +track=pu_kiskis_usen> redirects to <https://klamericas.s3.amazonaws.c +om/files/one/en/kis17.0.0.611en_10755.exe>

In reply to Re^3: URL Redirect by Todd Chester
in thread URL Redirect by Todd Chester

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.