From: "Rob Dixon" <[EMAIL PROTECTED]> > Nobody else has mentioned this, but I think it's nice to have a name > to write to. '[EMAIL PROTECTED]' and 'rkl' don't do a lot for me!
Agreed completely. > <[EMAIL PROTECTED]> wrote: > > > > 1 - What is the best char to use in a file template? > > Also, please give me a good regex? > > > > I will have a formatted html page with some keys that I want to > > replace. > > > > For example, > > > > ... > > <!-- here my token is a ! --> > > <td>First Name:</td><td>!fname!</td> > > <td>Last Name:</td><td>~!lname!</td> > > ... > > Unless there's a good reason not to, I would use an HTML comment tag > > <!-- fname --> > > <!-- lname --> > > etc. so that the HTML parses OK before the subtitutions are done. Well ... I like to be able to see the things I forgot to replace. I usualy use [% name %] for things that are to be replaced. > > 2 - Can I read in the whole page and do a replacement? > > I'm thinking it's either a line-by-line or a whole page as below: > > > > #line-by-line replace token > > $line ~= s/!fname!/$fname/ > > > > #or put the whole template in > > $page ~= s/!fname!/$fname/ > > $page ~= s/!lname!/$lname/ > > > Your substitution is fine, just add a /g to it to change all tags in > the string instead of just the first. Like this > > $line =~ s/<!-- fname -->/$fname/g; > > Unless you have a good reason to read in the whole file at once, > process it a record at a time. Of course keep in mind that your tokens cannot span several lines then: <!-- fname --> would not work. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]