Two things:
- You never saved anything back to your @links.
- There was no need to create that $uri variable unless you need it somewhere else.
use Data::Dumper;
use URI;
use strict;
use warnings;
my $base_url = "http://www.abc.com/";
my @links = qw/a b c/;
for my $index (0 .. $#links) {
$links[$index] = URI->new_abs($links[$index], $base_url)->as_strin
+g;
}
print Dumper(\@links);
You can use map instead of for loop:
use Data::Dumper;
use URI;
use strict;
use warnings;
my $base_url = "http://www.abc.com/";
my @links = qw/a b c/;
@links = map {URI->new_abs($_, $base_url)->as_string()} @links;
print Dumper(\@links);
Both gives:
$VAR1 = [
'http://www.abc.com/a',
'http://www.abc.com/b',
'http://www.abc.com/c'
];
|