K
Kirk Haines
I have some Perl code that does something like this:
$copy =~ s{<!--#include\s+virtual\s*=\s*"([^"]*)"\s*-->}{get($1)}gem
Basically, apply a regex to a string, and for every match, call get($1) and
replace the match with the return value of the get(). get() comes from
LWP::Simple, and simply fetches the content at the given URL.
My Ruby-fu is failing me at coming up with a relatively concise yet readable
way to do this in Ruby. My implementation is, I am sure, much longer than
necessary.
So, anyone have any ideas? How would you do this?
Kirk Haines
$copy =~ s{<!--#include\s+virtual\s*=\s*"([^"]*)"\s*-->}{get($1)}gem
Basically, apply a regex to a string, and for every match, call get($1) and
replace the match with the return value of the get(). get() comes from
LWP::Simple, and simply fetches the content at the given URL.
My Ruby-fu is failing me at coming up with a relatively concise yet readable
way to do this in Ruby. My implementation is, I am sure, much longer than
necessary.
So, anyone have any ideas? How would you do this?
Kirk Haines