cayenne has asked for the wisdom of the Perl Monks concerning the following question:
I have a subroutine that takes a chunk of html that is going to be in a menu with a different background than the main one and returns it with font color tags around links in one color and then with font color tags around those things which do not already have font tags around them (yes I know font tags are depricated. However I am trying to make my site compatable with things like netscape 3.01, in which that is the only way to change the color of the text.)
I haven't figured out a good way to do the latter part, and after staring at it for longer than I wanted to decided I'd ask other people for ideas.
Anyway, here's the thing at the moment (I don't seem to be terribly awake and perhaps code would be a little more coherent than:)
P.S. bonus points of you recognize the reference in the title.sub menucolor { my $stuff = join '', @_; my ($ls, $le, $ts, $te) = ($Q->start_font({-color => $Page{'owner' +}{'MenuLink'}}), $Q->end_font, $Q->start_font({-color => $Page{'owner +'}{'MenuText'}}), $Q->end_font); $stuff = "<>$stuff<>" if $stuff !~ /^<.*>$/; #color links link color $stuff =~ s/(<a\s[^>]*?>)([^<]+)/$1$ls$2$le/ig; #color everything currently uncolored text color $stuff =~ s/(>)([^<]+)/$1$ts$2$te/ig; #doesn't yet do what it's su +pposed to return $stuff; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: This is a job for... someone else.
by zengargoyle (Deacon) on Feb 24, 2002 at 10:03 UTC | |
|
Re: This is a job for... someone else.
by jonjacobmoon (Pilgrim) on Feb 24, 2002 at 14:55 UTC | |
|
Re: This is a job for... CGI.pm and HTML::Template
by dragonchild (Archbishop) on Feb 25, 2002 at 14:24 UTC |