月曜日, 1月 29, 2007

Perl, add session info to a tag like PHP

I's easy to add indo to a tag byHTML::StickyQuery

---------------------------
#!/usr/bin/perl

use strict;
use CGI;
use HTML::StickyQuery;

my $session = 12345678;

my $output;

$output =<< "HTML";
<html> <head> <title>Session Test</title> </head> <body> <a href="sample1.pl">link1</a><br> <hr> <a href="sample2.pl">link2</a><br> <hr> </body> </html>
HTML




# create html
my $cgi=CGI->new;
print $cgi->header(-charset=>'UTF-8');


my $stq = HTML::StickyQuery->new;
print $stq->sticky(
scalarref => \$output,
param => { SESSID => $session }
);

--result html--

<a href="sample2.pl?SESSID=12345678">