this a link:
somewhere

another place to go.

#### this a link: http://www.somewhere.org/foo another place to go: https://somewhere.else.net/bar/ #### #$unprocessed_html holds the text of the html version of my file #$unprocessed_text holds the plain text version of my file #@markers holds the unique url markers, ie [/qfk33pe][/nnd92093] #handle html version my $processed_html = ""; while (length($unprocessed_html) > 0) { if($unprocessed_html =~ s/^(.*?\b(href|action)\s*=\s*)//si) { $processed_html .= $1; } else { $processed_html .= $unprocessed_html; last; } if (not(@markers)){ $processed_html .= $unprocessed_html; warn "no more markers available for remaining links\n"; last; } if($unprocessed_html =~ s/^([^\"\'][^<>\s]*)//) { my $url = $1 . shift(@markers); #strip double //s due to sloppy input $url =~ s|//|/|g; $processed_html .= $url; } elsif($unprocessed_html =~ s/^([\"\'])([^<>]*?)\1//) { my $url = $1 . $2 . shift(@markers) . $1; #strip double //s that can result from sloppy input $url =~ s|//|/|g; $processed_html .= $url; } else { die "something happened here"; } } #handle text version my $processed_text = ""; while (length($unprocessed_text) > 0) { if($unprocessed_text =~ s/^(.*?\b)http/http/si) { $processed_text .= $1; } else { $processed_text .= $unprocessed_text; last; } if (not(@markers)){ $processed_text .= $unprocessed_text; warn "no more markers available for remaining links\n"; last; } if($unprocessed_text =~ s/(http[\S]+)\s+//){ my $urlfound = $1 . shift (@markers); $urlfound =~ s|//|/|g; $processed_text .= "$urlfound\n"; } elsif($unprocessed_text =~ s/(http[\S]+)$//){ my $urlfound = $1 . shift (@markers); $urlfound =~ s|//|/|g; $processed_text .= "$urlfound\n"; } }