Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: converting absolute to relative links

by repson (Chaplain)
on Feb 03, 2001 at 10:52 UTC ( #56211=note: print w/replies, xml ) Need Help??


in reply to converting absolute to relative links

The main wheels I would suggest would be HTML::Parser or any of several others in the HTML:: tree, and URI.

use URI; use HTML::Parser; my $parse = new HTML::Parser( default_h => [ sub {print shift}, 'text' + ], start_h => [ sub { my ($tag, $attr, $origtext) = @_; if (($tag eq 'img') and ($attr->{src} =~ m#^(?:http://)?myserver\. +#)) { $attr->{img} = URI->new($attr->{img})->abs('http://myserver.com' +); print "<$tag " . join (' ', map {$_.'="' . $attr->{$_} . '"'} ke +ys %$attr) . '>'; } else { print $origtext; } }, "tagname, attr, text"] ); $parse->parse(join('',<>));
However this code is untested and may well need some work. It currently would take input on STDIN and produce results on STDOUT.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://56211]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-01-22 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (62 votes). Check out past polls.

    Notices?