|There's more than one way to do things|
Modifying muliple matched strings in textby nysus (Parson)
|on Jul 12, 2020 at 12:18 UTC||Need Help??|
nysus has asked for the wisdom of the Perl Monks concerning the following question:
In the following piece of markdown text, I want to replace the spaces with a hyphen and also make the link absolute with a slash in front. So I want to go from:
So this is as far as I got and I'm stymied:
The obvious problem with this code is that only the first link gets the space replaced:
I'm drawing a blank on how I might loop through all matches to links and modify those matches. Or maybe there is an entirely better way of pulling this off. Thanks!
OK, I noodled around with this some more. On a lark, I tried a "global" match (which I didn't know existed outside substitution), and came up with this:
Though it seems to work, I have a hunch this isn't ideal.
$PM = "Perl Monk's";