Hi to the fellow monks

I have an array of url's that i have extracted from a website which means there are relative url's and absolute ones in my array. I have found the URI module which seems better than the URI::URL one, and am trying to make all my url's absolute. This is my code:

my $base_url = "http://www.perlmonks.com/"; my $uri = URI->new("http://www.perlmonks.com"); foreach(@links) { # This loop is to make all the relative url's absol +ute $uri = URI->new_abs( $_, $base_url ) } print "@links \n";

I have tried this but to no avail. The elements of the array still come out in the same way as they used to, some relative and some absolute. From the URI documentation there doesn't seem another good way of doing this. I think this should be pretty simple as i have the absolute url but i can't seem to do it. Any ideas? Thanks.


In reply to Turn relative url's to absolute with URI by lampros21_7

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.