I am attempting to reformat the structure of URL's inside a text file, but I am about pulling my hair out.
The urls are like this inside a text file:
In other words, every URL is butted up next to the other without a space in between. I want to return the text into an easy to use format like so:
The code I'm using is this:
$links[0] prints out the whole @links - not only the first link.
I'm not a programmer really, more of a hack that just knows a few things. . . but this has had me stopped up for over 2 hours. Any help would be appreciated.
Thanks.
The urls are like this inside a text file:
Code:
[URL unfurl="true"]http://www.domain.com/http://www.somesite.com/index.phphttp://www.[/URL] . .
In other words, every URL is butted up next to the other without a space in between. I want to return the text into an easy to use format like so:
Code:
[URL unfurl="true"]http://domain.com[/URL]
[URL unfurl="true"]http://www.example.com[/URL]
[URL unfurl="true"]http://site.com/folder/[/URL]
etc. . .
The code I'm using is this:
Code:
open(DATA, "data.txt") or die "you stupid script";
while (<DATA>) {
@links = split(/^http+$/, $_);
print "$links[0]\n";
}
close DATA;
$links[0] prints out the whole @links - not only the first link.
I'm not a programmer really, more of a hack that just knows a few things. . . but this has had me stopped up for over 2 hours. Any help would be appreciated.
Thanks.