Looking at this code, it already seems that you handle variables. So, let's see if we can get a SSI 'exec' in there, too.

Here is the code I just tested. It is a little different from the original (I removed the prototyping '()' from the function name, and changed the @_[0] to shift) just to make it work in my test.

sub DisplayHTML { $HTMLFileName = shift; open(HTMLFNH,"<$HTMLFileName") || die "ERROR: Can't open $HTMLFileName: $!"; print "Content-type: text/html\n\n"; while ($HTMLLine=<HTMLFNH>) { chomp $HTMLLine; $HTMLLine =~ s/(\$[\w\[\]{}']+)/'"'.$1.'"'/gee; if ($HTMLLine =~ /(.*?)<!--\s*#exec cmd=\"?(.*?)\"? -->(.*)/) { $HTMLLine = $1 . `$2` . $3; } print "$HTMLLine\n"; } close(HTMLFNH); }

It took a little work (on my part - still coming up to speed myself!), but this did test out in my scenario. Let me know if it works for you. I don't know if this is the 'best' way, but it is probably the easiest.

One thing I think I really have to say is that these SSI 'exec's can open a whole world of trouble, so be careful with the code the SSI is running.

D a d d i o


In reply to Re: SSI problem by Daddio
in thread SSI problem by akm2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.