this isn't a clean solution by any stretch of the imagination. one of the apps i'm dealing with the previous designer fetches a page from another server using LWP, dumps it into a variable, and passes that variable into a (badly done)
HTML::Template::load_tmpl wrapper.
while i'd love to spend the time cleaning it up, i just need to fix a display problem right now. because the headers are fetched, all the CSS information also gets fetched ( along w/ title, etc ), and it's blowing up the display.
here's what i've been trying to do, without much success:
## dummy URL
my $out = get("http://www.webpage.com");
+
+
$out =~ s/\cM//g;
## doesn't seem to match
$out =~ s#^<head>[\w|\s]+</head>#<!-- header removed -->#mio;
$out =~ s/<head>(.*?)</head>#<!-- header removed -->/im;
+
+
## these work ... but only take out one line
#$out =~ s#<html>#<!-- header removed -->#mi;
#$out =~ s#<title>(.*)</title>#<!-- header removed -->#mi;
#$out =~ s#<meta(.*)>#<!-- header removed -->#mi;
## also doesn't work
$out =~ s#<style type(.*?)</style>#<!-- header removed -->#im;
there may be a better, non-regex way ( and i'm open to suggestions ), but it seemed a brute force regex answer would be quick ....
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.