I'm grabbing a link from HTML and fixing it to take out the /../ and replace it with the absolute address. Here's the regex part of the code and some example variables.
$base_url =
"http://www.something.com/angels/devils";
$base_url =~ s!/[^/]*?$!!; #strip off the subdirectory
print "$base_url \n";
$address =
"http://www.something.com/angels/devils/../faries/";
$address =~ s!.*/\.\./(.*)!$base_url/$1!eg;
### stick this in &grabLinks ###
print "$address \n";
Output is:
http://leto.advtech.uswest.com/SERVICES
Illegal division by zero at line 14. #it's line 7 here...
I assume I'm doing something wrong with my formatting, but I can't figure it out. I tried adding {} brackets around the variable names but it wasn't working. Thanx for your help.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.