Gossamer Forum
Home : Products : DBMan : Customization :

Ideas/code for Parse/substitute pattern for a mod I am working on.

Quote Reply
Ideas/code for Parse/substitute pattern for a mod I am working on.
I have a line I want to parse and substitute.
Example:
$line contains ...
__________________
"the great red fox jumped <%anything%> the fence."
__________________
when read into my subroutine.
I am trying to create some code that will parse the "anything" out of the middle of the <%... and ... %>. (I need this part because I want this extraction so I can take some different actions upon the "anything".)
Then I want to substitute the <%anything%> with $mycontent.

Example:
$mycontent = "quickly over";

Sooooo, I would now want $line after all this code to contain...
$line contains ...
__________________
"the great red fox jumped quickly over the fence."
__________________

Any help on this would be appreciated
Thanks
TimRyan
Quote Reply
Re: Ideas/code for Parse/substitute pattern for a mod I am working on. In reply to
Talking to self here Smile. I just worked on and figured out part of idea for the latter code...
_________________
$parsethis = "<%db_uid%>";
if ($tmpl_line =~ /$parsethis/)
{
$tmpl_line =~ s/$parsethis/$db_uid/g;

}
__________________
.... and it works great Smile
But it is only a substitute part and I still need to figure the "grab-it" part. I would still like other ideas too Smile
TimRyan


[This message has been edited by timryan (edited August 14, 1999).]
Quote Reply
Re: Ideas/code for Parse/substitute pattern for a mod I am working on. In reply to
Have you taken a look at Template.pm in the Links distribution? I think it would pretty much take care of all this for you, although I can't be sure because I haven't looked at it closely.

I'm afraid you've gone beyond my expertise, though, so others will have to help you from here on out. Smile

------------------
JPD