GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
HTML::StickyQuery(3) User Contributed Perl Documentation HTML::StickyQuery(3)
 

HTML::StickyQuery - add sticky QUERY_STRING

  use HTML::StickyQuery;
  # create an object
  my $s = HTML::StickyQuery->new(
       regexp => '\.cgi$',
       abs => 0,
       keep_original => 1,
  );
  print $s->sticky(
      file => 'foo.html',
      param => { SESSIONID => 'xxx' }
  );
 or
  my $q = CGI->new;
  print $s->sticky(
      file => 'foo.html',
      param => $q,
      sticky_keys => [qw(SESSIONID)]
  );

this module is a sub class of HTML::Parser. parse HTML document and add QUERY_STRING to href attributes. Handy for maintaining state without cookie or something, transparently.
if you want to use sticky CGI data via FORM. it is better to use HTML::FillInForm.

new(%option)
constructor of HTML::StickyQuery object. the options are below.
abs
add QUERY_STRING to absolute URI or not. (default: 0)
override
this option is obsolete. please use keep_original option.
keep_original
keep original QUERY_STRING or not. (default: 1) when this option is false. all old QUERY_STRING is removed.
regexp
regular expression of affected URI. (default: none)

sticky(%options)
parse HTML and add QUERY_STRING. return HTML document. the options are below.
file
specify the HTML file.
scalarref
specify the HTML document as scalarref.
arrayref
specify the HTML document as arrayref.
param
QUERY_STRING data. as hashref or object which implements param method. (eg. CGI, Apache::Request)
sticky_keys
specify sticky data keys as arrayref. any keys which are not in this list are ignored. if not specified, all keys are kept.

typical example of CGI application using session.
use Apache::Session,HTML::Template and HTML::StickyQuery
template file:
 <html>
 <head>
 <title>Session Test</title>
 </head>
 <body>
 COUNT: <TMPL_VAR NAME="count"><br>
 <hr>
 <a href="session.cgi">countup</a><br>
 <hr>
 </body>
 </html>
session.cgi:
 #!perl
 
 use strict;
 use CGI;
 use HTML::Template;
 use HTML::StickyQuery;
 use Apache::Session::DB_File;
 
 my %session;
 my $cgi = CGI->new;
 
 # create session.
 my $id = $cgi->param('SESSIONID');
 tie %session,'Apache::Session::DB_File',$id,{
                                              FileName => './session.db',
                                              LockDirectory => './lock'
 };
 $session{count} = $session{count} + 1;
 
 my $tmpl = HTML::Template->new(filename => './test.html');
 
 $tmpl->param(count => $session{count});
 
 my $output = $tmpl->output;
 
 # no COOKIE
 print $cgi->header;
 
 my $stq = HTML::StickyQuery->new;
 print $stq->sticky(
     scalarref => \$output,
     param => { SESSIONID => $session{_session_id} }
 );

template file (simplified):
  <A href="./search.cgi?pagenum=<TMPL_VAR name=nextpage>">Next 20 results</A>
search.cgi:
  #!perl
  use CGI;
  use HTML::StickyQuery;
  use HTML::Template;
  my $query = CGI->new;
  my $tmpl  = HTML::Template->new(filename => 'search.html');
  # do searching with $query and put results into $tmpl
  # ...
  # set next page offset
  $tmpl->param(nextpagee => $query->param('pagenum') + 1);
  my $output = $tmpl->output;
  my $sticky = HTML::StickyQuery->new(regexp => qr/search\.cgi$/);
  print $query->header, $sticky->sticky(
      scalarref => \$output,
      param => $qyery,
      sticky_keys => [qw(search)]
  );

IKEBE Tomohiro <ikebe@livedoor.jp>

HTML::Parser HTML::FillInForm

Fixes,Bug Reports.
Tatsuhiko Miyagawa <miyagawa@bulknews.net>

Copyright(C) 2002 IKEBE Tomohiro All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2010-12-03 perl v5.28.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.