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:)

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; }
P.S. bonus points of you recognize the reference in the title.

In reply to This is a job for... someone else. by cayenne

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.