SPUG:RE: POD link question

Martin, Asa asa.martin at attws.com
Wed Feb 19 18:39:33 CST 2003


That worked fantastically. I modified it slightly but that is exactly
what I was trying to do. My problem was I didn't think to create a
subroutine and use that as well; I was trying to do it all in the
substitute line. Here is the final code (I use s/// instead of tr and I
added a i to the pod_line regex because my pod2html seems to output
uppercase <STRONG> lines:

sub modname_to_htmlfile { my $mod = shift; $mod =~ s/::/_/g; "$mod.html"
}

$pod_line =~ s[<strong>(\w+(::\w+)+)</strong>]
              [sprintf '<a
href="%s">%s</a>',modname_to_htmlfile("$1"),"$1"]ige;

Thank you so much! 

Asa

-----Original Message-----
From: Yitzchak Scott-Thoennes [mailto:sthoenna at efn.org]
Sent: Wednesday, February 19, 2003 3:56 PM
To: spug-list at pm.org
Cc: asa.martin at attws.com
Subject: Re: SPUG:POD link question


On Wed, 19 Feb 2003 15:14:37 -0800, asa.martin at attws.com wrote:
>I would like to replace all references to B<Module::Name> in my POD
with <A HREF="Module_Name.html">Module::Name</A>. References to scripts
could occur multiple times per line.
>
>I tried doing this with a regular expression, but I got stuck. It
seemed difficult to match both two and three levels deep of ::. I
actually think matching an arbitrary number deep would be better. Any
ideas?

Something like (untested):

sub modname_to_htmlfile { my $mod = shift; $mod =~ tr/:/_/s; "$mod.html"
}

$pod_line =~ s[<strong>(\w+(::\w+)+)</strong>]
              [sprintf '<a
href="%s">%s</a>',modname_to_htmlfile("$1"),"$1"]ge;

(assuming you are doing this after pod2html does its stuff).



More information about the spug-list mailing list