Currently I have a script that opens up a web page on my local NT workstation and substitutes relative path with an absolute path on one link. If I want to substitute a relative path on other links I have to write a substitute for each one. Anyway I could make this script substitute all relative paths and put in the absolute path for each one? I basically need to add <A HREF="http://www.mysite.com/ to each relative path. Here is one example:
relative link before my script: directory/file.doc after script: http://www.mysite.com/directory/file.doc
Now here is how I did it but want to know if I could do the same with all my relative links on this one webpage. I assume I need some reg expressions that is more complicated than what I have done?
my $db = 'webpage'l'; open(DATA, "$db") or die "File does not open: $!"; my @data = (<DATA>); close (DATA); open(DATA, ">$db") or die "File not open: $!"; foreach my $line (@data) { $line =~ s?<A HREF="directory/file.doc">?<A HREF="http://www.mysite. +com/directory/file.doc">?g; print DATA $line; }

In reply to Changing from relative to absolute path by Anonymous Monk

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.