CGI::Simple

CGI::Simple is a simple totally OO CGI interface that is CGI.pm compliant.
Download

CGI::Simple Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Andy Armstrong
  • Publisher web site:
  • http://search.cpan.org/~andya/

CGI::Simple Tags


CGI::Simple Description

CGI::Simple is a simple totally OO CGI interface that is CGI.pm compliant. CGI::Simple is a simple totally OO CGI interface that is CGI.pm compliant.SYNOPSIS use CGI::Simple; $CGI::Simple::POST_MAX = 1024; # max upload via post default 100kB $CGI::Simple::DISABLE_UPLOADS = 0; # enable uploads $q = new CGI::Simple; $q = new CGI::Simple( { 'foo'=>'1', 'bar'=> } ); $q = new CGI::Simple( 'foo=1&bar=2&bar=3&bar=4' ); $q = new CGI::Simple( *FILEHANDLE ); $q->save( *FILEHANDLE ); # save current object to a file as used by new @params = $q->param; # return all param names as a list $value = $q->param('foo'); # return the first value supplied for 'foo' @values = $q->param('foo'); # return all values supplied for foo %fields = $q->Vars; # returns untied key value pair hash $hash_ref = $q->Vars; # or as a hash ref %fields = $q->Vars("|"); # packs multiple values with "|" rather than "�"; @keywords = $q->keywords; # return all keywords as a list $q->param( 'foo', 'some', 'new', 'values' ); # set new 'foo' values $q->param( -name=>'foo', -value=>'bar' ); $q->param( -name=>'foo', -value=> ); $q->param( 'foo', 'some', 'new', 'values' ); # append values to 'foo' $q->append( -name=>'foo', -value=>'bar' ); $q->append( -name=>'foo', -value=> ); $q->delete('foo'); # delete param 'foo' and all its values $q->delete_all; # delete everything $files = $q->upload() # number of files uploaded @files = $q->upload(); # names of all uploaded files $filename = $q->param('upload_file') # filename of uploaded file $mime = $q->upload_info($filename,'mime'); # MIME type of uploaded file $size = $q->upload_info($filename,'size'); # size of uploaded file my $fh = $q->upload($filename); # get filehandle to read from while ( read( $fh, $buffer, 1024 ) ) { ... } # short and sweet upload $ok = $q->upload( $q->param('upload_file'), '/path/to/write/file.name' ); print "Uploaded ".$q->param('upload_file')." and wrote it OK!" if $ok; $decoded = $q->url_decode($encoded); $encoded = $q->url_encode($unencoded); $escaped = $q->escapeHTML('"&'); $unescaped = $q->unescapeHTML('"&'); $qs = $q->query_string; # get all data in $q as a query string OK for GET $q->no_cache(1); # set Pragma: no-cache + expires print $q->header(); # print a simple header # get a complex header $header = $q->header( -type => 'image/gif' -nph => 1, -status => '402 Payment required', -expires =>'+24h', -cookie => $cookie, -charset => 'utf-7', -attachment => 'foo.gif', -Cost => '$2.00' ); # a p3p header (OK for redirect use as well) $header = $q->header( -p3p => 'policyref="http://somesite.com/P3P/PolicyReferences.xml' ); @cookies = $q->cookie(); # get names of all available cookies $value = $q->cookie('foo') # get first value of cookie 'foo' @value = $q->cookie('foo') # get all values of cookie 'foo' # get a cookie formatted for header() method $cookie = $q->cookie( -name => 'Password', -values => , -expires => '+3d', -domain => '.nowhere.com', -path => '/cgi-bin/database', -secure => 1 ); print $q->header( -cookie=>$cookie ); # set cookie print $q->redirect('http://go.away.now'); # print a redirect header dienice( $q->cgi_error ) if $q->cgi_error;CGI::Simple provides a relatively lightweight drop in replacement for CGI.pm. It shares an identical OO interface to CGI.pm for parameter parsing, file upload, cookie handling and header generation. This module is entirely object oriented, however a complete functional interface is available by using the CGI::Simple::Standard module.Essentially everything in CGI.pm that relates to the CGI (not HTML) side of things is available. There are even a few new methods and additions to old ones! If you are interested in what has gone on under the hood see the Compatibility with CGI.pm section at the end.In practical testing this module loads and runs about twice as fast as CGI.pm depending on the precise task.Requirements:· Perl Requirements: · Perl


CGI::Simple Related Software