in reply to Re: br tag in CGI.pm V2.91
in thread br tag in CGI.pm V2.91

I just ran this:
#!/usr/bin/perl use strict; use CGI; my $q = CGI->new(); print "$CGI::VERSION\n"; print $q->br."\n"; # and it output this: 2.91 <br></br>

Very weird.

cLive ;-)

Replies are listed 'Best First'.
Re: Re: Re: br tag in CGI.pm V2.91
by BrowserUk (Patriarch) on Apr 09, 2003 at 23:25 UTC

    I just pulled 2.91 and I get the same results as you.

    C:\test>perl -mCGI -le"$q=new CGI; print $CGI::VERSION; $CGI::XHTML=1; + print $q->br;" 2.91 <br></br>

    I even tried explicitly setting $CGI::XHTML = 1; directly--even though it appears to be set to this at line 45 of CGI.pm, and the only place where I can see that it gets modified is at line 718 as a result of the -no_xhtml option. The code generating the BR markup

    1948 $break = $XHTML ? "<br />" : "<br>"; 2116 $break = $XHTML ? "<br />" : "<br>";

    looks like it ought to do the right thing.

    Upshot: I guess it's time to send Lincoln Stein a bug report. You could try for a patch as well, but I'm scuppered if I can see where to patch:)


    Examine what is said, not who speaks.
    1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
    2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
    3) Any sufficiently advanced technology is indistinguishable from magic.
    Arthur C. Clarke.

      Update: this is actually redundant This Node has a better explanation...

      If it were only that simple :) If you'd looked above these lines, you would have seen that they were within the 'checkbox_group' and 'radio_group' subs (although I think your line number is off in the second case). You need to do a little less casual grepping :)

      After a little play, I think I've narrowed it down to (and sent a note to Lincoln explaining my thoughts) this sub:

      sub _make_tag_func { my ($self,$tagname) = @_; my $func = qq( sub $tagname { shift if \$_[0] && (ref(\$_[0]) && (substr(ref(\$_[0]),0,3) eq 'CGI' || UNIVERSAL::isa(\$_[0],'CGI'))); my(\$attr) = ''; if (ref(\$_[0]) && ref(\$_[0]) eq 'HASH') { my(\@attr) = make_attributes(shift()||undef,1); \$attr = " \@attr" if \@attr; } ); if ($tagname=~/start_(\w+)/i) { $func .= qq! return "<\L$1\E\$attr>";} !; } elsif ($tagname=~/end_(\w+)/i) { $func .= qq! return "<\L/$1\E>"; } !; } else { $func .= qq# return \$XHTML ? "\L<$tagname\E\$attr />" : "\L<$tagname\E\$at +tr>" unless \@_; my(\$tag,\$untag) = ("\L<$tagname\E\$attr>","\L</$tagname>\E") +; my \@result = map { "\$tag\$_\$untag" } (ref(\$_[0]) eq 'ARRAY') ? \@{\$_[0]} : +"\@_"; return "\@result"; }#; } return $func; }
      My guess is that \@_ is always true at the moment, so it never tries to create the XHTML non-container element (it's a little easier to see if you dump the output of the compiled br sub).

      cLive ;-)

        You need to do a little less casual grepping :)

        Your right. In future I won't pass along any information until I've solved your problem.


        Examine what is said, not who speaks.
        1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
        2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
        3) Any sufficiently advanced technology is indistinguishable from magic.
        Arthur C. Clarke.