NAME

PSP::CGI::Generate - exports code generation functions commonly used in CGI programs.


SYNOPSIS

  my $string = generateForm($hash,\%hash,
      {
        key1 => 'value in anonymous hash',
        key2 => 'another value!'
      }
    );
  
  my $string = generateForm(%hash);
  
  my $string = generateForm(
      key1 => 'value from a common hash',
      key2 => 'another value!'
    );
  
  my $string = generateGet($hash,\%hash,
      {
        key1 => 'value in anonymous hash',
        key2 => 'another value!'
      }
    );
  
  my $string = generateGet(%hash);
  
  my $string = generateGet(
      key1 => 'value from a common hash',
      key2 => 'another value!'
    );


DESCRIPTION

This module exports few functions that generate XHTML code and HTTP request strings from Perl data structures. This module was creates as a companion to the Perl Script Pages Engine. See the PSP::Engine manpage for more information.


OVERVIEW

Exported Functions

generateForm
Generates a XHTML 1.1 compliant <input type=``hidden''> tags from either one or more references to hashs or anonymous hashs or from a single regular hash. See generateForm function for details.

generateGet
Generates a HTTP GET string from either one or more references to hashs or anonymous hashs or from a single regular hash. See generateGet function for details.


SYNTAX

generateForm Function

Generates a XHTML 1.1 compliant <input type=``hidden''> tags from either one or more references to hashs or anonymous hashs.

  my $string = generateForm($hash,\%hash,
      {
        key1 => 'value in anonymous hash',
        key2 => 'another value!'
      }
    );

or from a single regular hash:

  my $string = generateForm(%hash);
  
  my $string = generateForm(
      key1 => 'value from a common hash',
      key2 => 'another value!'
    );

The last example will generate the following XHTML code: ``<input type="hidden" name="key1" value="value from a common hash" /><input type="hidden" name="key2" value="another value!" />''

The keys and values are automatically passed through the htmlize function from PSP::CGI::Transform, so you do not need to take care for quoting or XHTML compliance in your input data.

This function is exported automatically.

Required Parameters

$hash or \%hash
One or more references to hashs or an anonymous hashs to create the XHTML code from.

%hash
A common hash to create XHTML code from.

Optional Parameters

None.

Return Values

$string
Returns a text string containing the resulting XHTML code.

generateGet Function

Generates a HTTP GET string from either one or more references to hashs or anonymous hashs.

  my $string = generateGet($hash,\%hash,
      {
        key1 => 'value in anonymous hash',
        key2 => 'another value!'
      }
    );

or from a single regular hash:

  my $string = generateGet(%hash);
  
  my $string = generateGet(
      key1 => 'value from a common hash',
      key2 => 'another value!'
    );

The last example will generate the following HTTP GET string: ``key1=value+from+a+common+hash&key2=another+value%21''

As the return string may contain ``&'' characters, please remember to pass it through the htmlize function from PSP::CGI::Transform or use the PrintSecureOpenTag if you want to print the resulting data into (X)HTML code.

This function is exported automatically.

Required Parameters

$hash or \%hash
One or more references to hashs or an anonymous hashs to create the HTTP GET string from.

%hash
A common hash to create HTTP GET string from.

Optional Parameters

None.

Return Values

$string
Returns a text string containing the resulting HTTP GET string.


AUTHOR

Veit Wahlich

E-Mail: cru |at| zodia |dot| de

WWW: http://home.ircnet.de/cru/


VERSION

v0.7 Wednesday, 18 January 2006


COPYRIGHT/LICENSE

Copyright 2004-2006 Veit Wahlich

This software is distributed as free (libre) software under the terms of the GNU General Public License, version 2 <http://www.gnu.org/copyleft/gpl.html>. The author disclaims responsibility of any damage or harm caused directly or indirectly by usage of this software. Use only at your own risk.