thanks, andy t.#!/usr/local/bin/perl -w use strict ; use English ; use Socket ; use CGI qw/:all/ ; my($rec) ; my(@Record) ; my($cgi) ; my(%Hash) ; my($String) ; my($item) ; $cgi = new CGI ; # # See if there were passed values from the input form # if ( $cgi->param('string') ) {$String = $cgi->param('string') ;}; if ( $cgi->param('array') ) {@Record = $cgi->param('array') ;}; # If string has a value, then do the following. If not, # present the input form. if ( $String ) { Header() ; print "The String is: $String<br>\n" ; print "The Array has in it:<br>\n" ; foreach ( @Record ) { print "File: $_->{file}\n" ; print "Item: $_->{item}\n" ; } ; print "We're done.....\n" ; closeHTML() ; # This is the input form....... } else { # Load up the array with some stuff.... $rec->{'file'} = "/usr/local/bin/myfile" ; $rec->{'item'} = "type: file" ; push ( @Record, $rec ) ; $rec->{'file'} = "/usr/local/bin/ourfile" ; $rec->{'item'} = "type: file" ; push ( @Record, $rec ) ; Header(); print "<FORM ACTION=\"/cgi-bin/test_ray.cgi\" METHOD=\"POST\" " ; print " enctype=\"multipart/form-data\" " ; print "<P><B>Enter a string in this box:</b>" ; print "<BR><INPUT TYPE=TEXT NAME=\"string\" "; print "VALUE=\"$String\" SIZE=15>\n" ; print hidden('array', @Record) ; print "<INPUT TYPE=SUBMIT VALUE=\"Submit Request\"> " ; print "<INPUT TYPE=RESET VALUE=\"Reset Form\"></form>\n" ; closeHTML(); } ; ############### HTML Header ################### sub Header { print "content-type: text/html\n\n" ; print "<html>\n" ; print "<head>\n" ; print "<title>Pass the array</title>\n" ; print "</head>\n" ; print "<h1>\n" ; print "Array:\n" ; print "</h1>\n" ; print "<body bgcolor=white>\n" ; print "<font color=black>\n" ; } ; ################# close HTML ################## sub closeHTML { print "</font>\n" ; print "</body>\n" ; print "</html>"; } ;
In reply to passing/retrieving arrays by andy_t
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |