wolverina has asked for the wisdom of the Perl Monks concerning the following question:

this line of code inserts a value into the variable (random). The problem i'm having is that because the variable (random) is inside a server side include, the entire line is being intpreted instead of just the (random) variable. Anyone know how to fix the line so that only the (random) variable is intrepreted? Here's the line: <!--#exec cgi="/cgi-local/<!--random1-->" --> Thanx, Lisa.

Replies are listed 'Best First'.
Re: Parsing Server Side Includes
by cjf-II (Monk) on Nov 22, 2002 at 04:11 UTC

    Using HTML::TokeParser you can grab the SSI and then split it on the --s to grab the variable:

    use diagnostics; use strict; use warnings; use HTML::TokeParser; my $p = HTML::TokeParser->new("ssi.html") || die $!; my $randomVar; while (my $token = $p->get_token) { my $tokenType = shift @{$token}; if ($tokenType eq "C") { # add another loop in to check if it's the right ssi my @parts = split /--/, shift(@{$token}); $randomVar = $parts[2]; } } print $randomVar, "\n";

    Hope that helps.

      thanx... it did. :) Lisa
Re: variable insertion
by wolverina (Beadle) on Nov 22, 2002 at 03:08 UTC
    PS.. the line of code above is part of an htm file that is being parsed by a cgi script, that inserts a value in place of (random). -Lisa