Here the code
#perl! -w use CGI qw /:standard -nph/; $|++; $q=new CGI; my @commands = qw(ping traceroute whois ); my $dispatch = { ping => sub { return my_ping($_[0])}, traceroute => sub { return my_traceroute($_[0])}, }; %corrispondenze=( 'wy2khost1'=>'193.110.128.41' , 'wy2khost2'=>'193.110.128.42', 'wy2khost3'=>'193.110.128.52', 'wy2khost4'=>'193.110.136.130' ); print $q->header(); print $q->start_html(-bgcolor=>"#000099",-text=>"#FFCC00"); print $q->h2('prova'); print $q->start_form(-method=>'POST',-action=>'formDB2.cgi'); print $q->p('immettere qs '); print $q->textfield(-name=>'qs',-value=>""); print $q->submit; $val=$q->param('qs'); if ($val){print $q->hr;print "Hai messo: $val";print $q->hr;&trovabis( +$val)} sub trovabis { $indice=0; $cosa=shift; chomp $cosa; open (FH, 'C:\\Inetpub\\wwwroot\\PERL\\cgi-bin\\030716.txt')||die $! +; while (<FH>){push(@logline, $_)} foreach $record(@logline) { my @ciccio=split/\?/,$record; pop @ciccio; #toglie il valore nullo perché la stringa si chiude c +on un ? if ($ciccio[2]=~/$cosa/ || $ciccio[3]=~/$cosa/ || $ciccio[14]=~/$co +sa/ ) { $indice++; print table({-border=>0,-width=>"100%", -cellspacing=>"0", -cellpa +dding=>"0"}, Tr({-align=>LEFT,-valign=>TOP}, [ td([$q->h5("$indice)"),"$ciccio[0]($corrispondenze{$ciccio[ +0]})"]), td([$q->a({-href=>"http://$ciccio[2]",target=>new},"$ciccio +[2]"),"$ciccio[4]"]), td(["$ciccio[3]","$ciccio[7]"]), td(['',"$ciccio[9]"]), td(['',"$ciccio[10]"]), td(['',"$ciccio[11]"]), td(['',"$ciccio[14]"]), td(['',"$ciccio[15]"]), ] ) ); print $q->p("\$ciccio[2]vale $ciccio[2]"); print $q->start_form(-method=>'POST',-action=>'formDB2.cgi'); print $q->hidden(-name=>'val',-value=>"$ciccio[2]"); print $q->submit(ucfirst($_)) foreach (@commands); print $q->end_form; foreach (@commands) { $dispatch->{$_}->("$ciccio[2]") if (defined $q->param(ucfirst( +$_))); #$q->param('val') } print $q->hr; } } } sub my_ping { my $pingalo=shift; open (FH,"ping -n 1 -l 8 $pingalo|"); while (<FH>){if ($_=~/(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/){$risu +ltato_ping=$1}} close FH; print "$pingalo pinga su $risultato_ping";#debug info }

In reply to Re: Re: CGI auto incrementing table by Discipulus
in thread CGI auto incrementing table by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.