http://qs1969.pair.com?node_id=11134139

edwardsmarkf has asked for the wisdom of the Perl Monks concerning the following question:

hello - i am trying to format a large table in an existing perl script. when i use

$cgi->TR ( { -height => '100', -valign => 'bottom' } ...

the html is appearing with just:

<tr bottom height="100">

and i was hoping for this:

<tr valign='bottom' height="100">

it behaves as if somehow the "-valign" part is being "optimized" away, perhaps for a much older standard of html tables.
is there some easy workaround to this issue? i dont have time to re-do all this with some slick css option.

This is perl 5, version 26, subversion 3 (v5.26.3)

Replies are listed 'Best First'.
Re: strange output using -valign
by kcott (Archbishop) on Jun 22, 2021 at 06:16 UTC

    G'day edwardsmarkf,

    Welcome to the Monastery.

    You have a simple typo. The '=' in "-valign = 'bottom'" should be '=>'; cf. "-height => '100'".

    — Ken

      that was typo, sorry. similar to the "stubmit" button on the perlmonks edit page. 😁 had i used the code without the arrow, i assume it would have thrown an error.

        You have changed the text of your post without indicating that you did so.

        My post, with "-valign = 'bottom'", will not make sense to subsequent readers. I also see that tangent has wasted time trying figure out what's wrong with "-valign => 'bottom'" (see his post).

        I know you're new here and I'm not trying to beat over the head with a rule book. It is fine to make edits to your posts but you need to indicate what you've changed. Please read "How do I change/delete my post?" and add an Update: paragraph to your post.

        — Ken

Re: strange output using -valign
by tangent (Parson) on Jun 22, 2021 at 21:11 UTC
    Are you sure there isn't a mistake somewhere else - maybe post some more context. When I run your example it works fine. Using CGI version 4.44
    use CGI; my $cgi = CGI->new; my $html = $cgi->TR( { -height => '100', -valign => 'bottom' }, [ $cgi->th(['Vegetable', 'Breakfast','Lunch','Dinner']), $cgi->td(['Tomatoes' , 'no', 'yes', 'yes']), ] ); print "$html";
    OUTPUT:
    <tr height="100" valign="bottom"> <th>Vegetable</th> <th>Breakfast</th> <th>Lunch</th> <th>Dinner</th> </tr> <tr height="100" valign="bottom"> <td>Tomatoes</td> <td>no</td> <td>yes</td> <td>yes</td> </tr>
Re: strange output using -valign
by hippo (Bishop) on Jun 22, 2021 at 08:49 UTC
Re: strange output using -valign
by shmem (Chancellor) on Jun 22, 2021 at 04:29 UTC
    is there some easy workaround to this issue?

    Quick fix:

    print q(<tr valign="bottom" height="100">);
    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re: strange output using -valign
by AnomalousMonk (Archbishop) on Jun 22, 2021 at 00:23 UTC
Re: strange output using -valign (CGI.pm version?)
by Anonymous Monk on Jun 22, 2021 at 02:36 UTC
    (CGI.pm version?) Make your own function? Switch to templates? Take over CGI.pm support and start fixing html generation bugs? The choice is yours :;)