I was creating a table of URI encodings of ASCII characters as an appendix for my CGI course. Naturally, I figured that rather than create the table by hand, I'd write a script to do it, but I encountered an odd problem. Here's my code:
#!C:/perl/bin/perl.exe -w use strict; use URI::Escape; use CGI qw/:no_debug/; my $q = CGI->new(); my $file = "encodeTable.html"; my $outdata = ""; open OUT, ">$file" or die "Cannot open $file: $!\n"; for ( 0 .. 255 ) { my $char = chr( $_ ); my $escaped = uri_escape( $char ); unless ( $escaped ne '%20' ) { $escaped .= ' or +' }; $outdata .= $q->Tr( $q->td( { -align => 'right' }, [ $_ < 33 ? '&nbsp;' : $char, $_ , $e +scaped ] ) ); } print OUT $q->start_html( -title => "Uri Character Codes", -style => { src => '../style.css' }, -author=> 'poec@yahoo.com' ), $q->table( { -border => 1 }, $q->Tr ( $q->th( [ 'Symbol', 'ASCII Value', 'URI +encoded' ] ) ), $outdata ), $q->end_html; close OUT;
Now the above code works just fine. Unfortunately, all of the HTML runs together in one big line (which is fine if I'm conserving bandwidth). However, I decided to change the use CGI qw/:no_debug/; line to use CGI::Pretty qw/:no_debug/; and discovered that with this one simple change, the <TD ALIGN="right"> and the <TABLE BORDER="1"> tags have their attributes stripped, thus changing the appearance of the table. Searching through the POD has proved fruitless. Does CGI::Pretty strip attributes deliberately? Is this a known bug?

I'm using CGI.pm version 2.74 and CGI::Pretty version 1.04. Both of these appear to be the most up-to-date versions. If I am missing something, please let me know!

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just go the the link and check out our stats.


In reply to Bug in CGI::Pretty? by Ovid

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.