in reply to SSI Emulation Library

chipmonk makes a very good point about multiple SSI directives on one line. You might consider doing something like: $html =~ s/<!--#(.+?)-->/&expand_directive($1)/ge; For some hints on fleshing out the other SSI directives, take a look at my SSI script. You're welcome to borrow the code.