in reply to CGI Tables

You can't quite do it that way. Rember that each CGI HTML function returns a bit of text that has to be used. Inside that while loop, you're just discarding the results. They're not being fed back into the main table() call. What you need is something like this:
print $html_page->table( $html_page->tr( map { $html_page->td($_) } .... ) );
This will probably have to be re-tooled for your application. Remember that a while call does not return any data, yet a map call does. Update: I think Zaxo has a more thorough example.

As a note, I would shorten your $html_page variable. Single-letter variable names are fine, provided it's clear what they are. I frequently use $q for a CGI query, $r for an Apache request, and so forth. It gets kind of difficult to type out seven letters instead of two. Laziness, I know.

Replies are listed 'Best First'.
Long identifiers are fine (Re^2: CGI Tables)
by Flexx (Pilgrim) on Sep 02, 2002 at 10:20 UTC

    Uh! Bad advice (the "shorten your variable names", not the map example)! Sorry, just my humble opinion.

    As soon as the scope of the variable you use is larger than 5 lines, use Identifiers::Long! ;)

    Then, if it's just 5 lines, you'll survive typing a long name two or three times either. When someone else will need to read your code -- and after 6 Months you yourself are someone else -- he'll be glad to have meaningful names.

    I banned $i for counters right after school (where the formula's my programs were based on used i, of course), and I never missed it. Even if it's an iteration I'd rather use $iteration_count. And in case of indices it's nice to expess what your're indexing.

    And let's be honest, typing $request especially in a coding situation takes me no longer that typing $r. Well almost... It surely takes more time to read (and lookup/translate and undestand) $r for anyone not knowing the obvious...

    If I don't want to repeatedly type an identifier with a fancy name I simply cut and paste. Of course, it's good to know how to do that using your keyboard... ;)

    There's enough abbreviation in Perl anyway ($_, $a, $b, $#array, etc.).

    So, while I'm with you that obfuscuated perl is cool and fun, yet for serious work it's cool to use @long_names, and lame to be $lzy.

    So long,
    Flexx

    PS: I know I am a style phanatic.

    Update: Humm... I just realized I talked back to a saint... :] (...) a lazy saint. ;)

      Think of variable names in a LZW compression style. The more you use it, the shorter it can get, but to a point. I was just saying that for things you use capital-A All The Time, you can get by with a single letter. For me, $r is Always the same thing. It's sacred.

      If you want, you can call it $apr, or whatever, but things like $apache_request are kind of like naming your dog The Happy Canine Who Is My Life-Long Friend Named Spot. When you're talking about $dbh or $cgi, you should have an idea what you're dealing with.

      What I don't like is functions like this:
      sub mulch { my ($x, $z, $zz, $a) = @_; $x->foo($z, $zz, $a->id()); $z->insert($x); $a->restore(); return $x; }
      Isn't that informative? Without backtracing through caller after caller, you have no idea what type the variables are. Sure, you could put in some diagnostic code, but isn't that kind of absurd?

      All I'm saying is that if you use someting A Lot, you can reduce the letter count accordingly. If you use it almost never, you should be pretty clear as to what it is.

        Sure, you're right, $dbh, $sth (and $foo and $bar ;) and the like are almost reserved words... ;)

        The sorry thing is, there's a lot of mulch() out there...

        However in a script where I use HTTP::Request, CGI, and XML::Parser I'd still rather have $parser, $query and $request instead of $p, $q and $r.

        But maybe that's just because qbpd are just mirrors and rotations of each other... ;)

        Cheers,
        Flexx