Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Stripping CGI.pm tags

by ldude7 (Initiate)
on Nov 06, 2008 at 23:53 UTC ( [id://722109]=perlquestion: print w/replies, xml ) Need Help??

ldude7 has asked for the wisdom of the Perl Monks concerning the following question:

I have a big legacy app with a bunch of CGI.pm tags like: li(font({-face=>'verdana, arial, sans-serif', -color=>'red'}, $errorstring))

However, I have been tasked with redesigning the site, and need to be able to do most of the styling with CSS. I'm kind of stumped on a clean way to clean them up. My first stab was to try a simple regex:

find . |xargs grep -l 'font' | xargs perl -ne 'if(s/font\s*\(([^()]+)\) )/<span class="$1"/g) {print;}'

However, that seems to be heading somewhere int he right direction, but not really what I want. A better approach may be to split up the tags and just dump portions in a class (perhaps something like <li><span class="verdana red">$errorstring</span></li>

Is there a simple way to do that in regex? Or is there a better approach to cleaning up the cgi.pm code?

Replies are listed 'Best First'.
Re: Stripping CGI.pm tags
by f00li5h (Chaplain) on Nov 06, 2008 at 23:59 UTC

    you could play with CGI.pm's innards to get a stack trace when font is called...

    use CGI::Carp qw[ confess ]; my $old_font = \&CGI::font; *CGI::font = sub { confess "font here!"; $old_font(@_) };

    or you can just replace it with a sub that returns a "<span class=""> with the class determined by what's passed in...

    (udpate: this does involve you editing the code manually though)

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://722109]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-23 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found