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";