in reply to CGI form Not Showing Up.

Another question of style -- why not use CGI.pm's routines for all of your table items as well?
print table( Tr( br, br, td( b( u( "IPS" ) " - " ) ), @ips, br, br ), Tr( br, br, td( b( u( "CNames" ) " - " ) ), @names, br, br ), Tr( br, br, td( b( u( "Services" ) " - " ) ), @services, br, br ), Tr( br, br, td( b( u( "Banners" ) " - " ) ), @banners, br, br ) );
(Note: I haven't tested this code!)

You could do something even cooler by having the titles and arrays stuffed into an array. Later, adding a new row to your report would just mean adding a line to the array -- without code changes! (That's the Lazy part of Laziness, Impatience and Hubris in Perl.)

--t. alex

"Nyahhh (munch, munch) What's up, Doc?" --Bugs Bunny

Replies are listed 'Best First'.
Re: Re: CGI form Not Showing Up. (Style Comment)
by thunders (Priest) on May 01, 2002 at 18:46 UTC
    (Note: I haven't tested this code!)
    You only want td() or th() elements directly inside of Tr() elements, otherwise the content will print out somewhere strange. this is closer:
    #!/usr/bin/perl use CGI qw/:standard/; sub nl{ return qq(\n) } @ips = ("1.2.3.4","2.4.6.8","3.6.9.12"); @names = ("A1","B2","C3"); @services = ("srv1","srv2","srv3"); @banners = ("ban1.1","ban2.2","ban3.3"); print table( Tr([ td(br.br.b(u("IPS")." - @ips".br.br)).nl, td(br.br.b(u("Names")." - @names".br.br)).nl, td(br.br.b(u("Services")." - @services".br.br)).nl, td(br.br.b(u("Banners")." - @banners".br.br)).nl, ]).nl, ).nl;
      Good one, although I note that you're using concatenation rather than the more efficient list separator ('.' as opposed to ','). And what's the nl for?

      --t. alex

      "Nyahhh (munch, munch) What's up, Doc?" --Bugs Bunny

        ok the nl function is just ultimate laziness it's two characters shorter than "\n" and four shorter than qq(\n). i like new lines in my HTML. It should really be &nl so i don't have to define it up top.
        As for the concat, in this case it works same as , but if you use brackets
        td(["bob "."dan","alice"])
        to construct a row of td()'s it makes a big difference wheather you concat or commify. you get
        <td>bob dan</td><td>alice</td>
        So habitually i use . for things in one td cell. I doubt the overhead is noticible.