User Tools

Site Tools


cgi_jquery

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
cgi_jquery [2022/10/17 12:36] – created admincgi_jquery [2022/10/17 12:57] (current) admin
Line 11: Line 11:
         });         });
 </code> </code>
 +Perl code:
 +<code>
 +#!/usr/bin/perl
 +use strict;
 +use JSON;
 +use Data::Dumper;
 +open OUT,">","/tmp/perl.out";
 +print "Content-Type: text/html; charset=windows-1251\n\n";
 +my $buffer;
 +read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 +my $json = decode_json($buffer);
 +print OUT "Splitting\n";
 +my @pairs = split(/&/, $json);
 +my $n=scalar(@pairs);
 +print OUT "THere are $n values\n";
 +#print OUT Dumper(@pairs);
 +my %FORM;
 +foreach my $pair (@pairs) 
 +{
 +    my ($name, $value) = split(/=/, $pair);
 +
 +    $FORM{$name} = $value;
 +
 +}
 +print OUT "Printing form\n";
 +print OUT Dumper(%FORM);
 +</code>
 +
 +Output (edited):
 +<code>
 +
 +Splitting
 +THere are 24 values
 +Printing form
 +$VAR1 = 'query';
 +$VAR2 = '                    ';
 +$VAR3 = 'xSORT';
 +$VAR4 = '_OSORT_';
 +$VAR5 = 'xDB';
 +$VAR6 = '_ODB_';
 +$VAR7 = 'xTERMS';
 +$VAR8 = '_OTERMS_';
 +$VAR9 = 'xAND';
 +$VAR10 = '_OAND_';
 +$VAR11 = 'CK_imap.gmail-3.com.db';
 +$VAR12 = 'CK_imap.gmail-3.com.db';
 +...
 +</code>
 +
 +Dump is weird.  It dumps hashes as an array of pairs so this is what the hash really looks like:
 +<code>
 +{"query":""
 +"CK_imap.gmail-3.com.db":"CK_imap.gmail-3.com.db"
 +"xDB":"_ODB_"
 +"xSORT":"_OSORT_"}
 +...
 +</code>
 +
 +Also one way to initialize a hash:
 +<code>
 +my %rec_hash = ('name'=>$name, 'type'=>$type,'data'=>$data,'ttl'=>$ttl);
 +</code>
 +
 +
cgi_jquery.1666002989.txt.gz · Last modified: 2022/10/17 12:36 by admin