texasperl has asked for the wisdom of the Perl Monks concerning the following question:
Many thanks in advance.#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw( fatalsToBrowser ); # not leaving in production! # this is hackish and ugly using n_ for keys, but sort() likes it my %swip_data = ( "02_org_name" => "", "03_org_addr1" => "", "03_org_addr2" => "", "04_org_city" => "", "05_org_st" => "", "06_org_zip" => "", "07_org_cc" => "", "09_poc_type" => "", "10_poc_role" => "", "12_poc_cname" => "", "13_poc_addr1" => "", "13_poc_addr2" => "", "14_poc_city" => "", "15_poc_st" => "", "16_poc_zip" => "", "17_poc_cc" => "", "18_poc_phone" => "", "19_poc_email" => "", "20_ip_addr" => "", "21_netname" => "", ); my $cgi = new CGI; print $cgi->header; print $cgi->start_html(-title => "ARIN SWIP Generator"); print "Welcome to the ARIN Shared WHOIS Project Template Filler!<br>"; print "In development...pretty straightforward although your mileage m +ay vary.<br>Please check results for sanity!"; print "<br><br>"; my @sorted = sort keys %swip_data; # loop through our ordered keys and match fields to template values print $cgi->start_form(); foreach (@sorted) { print "$_ :" . $cgi->textfield(-name => "$_") . "<br>"; } foreach (@sorted) { if (defined $cgi->param("$_")) { $swip_data{$_} = $cgi->param("$_"); } else { print "You must define a $_." . "<br>"; } } print $cgi->submit(-value => 'Black Magic'); print $cgi->end_form(); my $arin_tmpl = <<END_TMPL Template: ARIN-REASSIGN-DETAILED-4.0<br> ** As of September 2006<br> ** Detailed instructions are located below the template<br>. 01. Downstream Org ID:<br> 02. Org Name: $swip_data{'02_org_name'}<br> 03. Org Address: $swip_data{'03_org_addr1'}<br> 03. Org Address: $swip_data{'03_org_addr2'}<br> 04. Org City: $swip_data{'04_org_city'}<br> 05. Org State/Province: $swip_data{'05_org_st'}<br> 06. Org Postal Code: $swip_data{'06_org_zip'}<br> 07. Org Country Code: $swip_data{'07_org_cc'}<br> 08. Org POC Handle:<br> 09. Org POC Contact Type (P or R): $swip_data{'09_poc_type'}<br> 10. Org POC Last Name or Role Account: $swip_data{'10_poc_role'}<br> 11. Org POC First Name: <br> 12. Org POC Company Name: $swip_data{'12_poc_cname'}<br> 13. Org POC Address: $swip_data{'13_poc_addr1'}<br> 13. Org POC Address: $swip_data{'13_poc_addr2'}<br> 14. Org POC City: $swip_data{'14_poc_city'}<br> 15. Org POC State/Province: $swip_data{'15_poc_st'}<br> 16. Org POC Postal Code: $swip_data{'16_poc_zip'}<br> 17. Org POC Country Code: $swip_data{'17_poc_cc'}<br> 18. Org POC Office Phone Number: $swip_data{'18_poc_phone'}<br> 19. Org POC E-mail Address: $swip_data{'19_poc_email'}<br> ** NETWORK SECTION<br> 20. IP Address and Prefix or Range: $swip_data{'20_ip_addr'}<br> 21. Network Name: $swip_data{'21_netname'}<br> END_TMPL ; print $arin_tmpl; print $cgi->end_html();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to loop through CGI params and insert into a heredoc?
by fenLisesi (Priest) on Oct 20, 2006 at 17:52 UTC | |
|
Re: How to loop through CGI params and insert into a heredoc?
by shmem (Chancellor) on Oct 20, 2006 at 21:40 UTC |