I don't think you are missing something, it looks like it really is a bug (or at least an oversight). The code that generates this html looks like this (this is the end of a sub generated by _make_tag_func which is called by AUTOLOAD in CGI.pm):

return $XHTML?"\L<br\E$attr />":"\L<br\E$attr>" unless @_; my($tag,$untag) = ("\L<br\E$attr>","\L</br>\E"); my @result = map { "$tag$_$untag" } (ref($rest[0]) eq 'ARRAY') ? @{$rest[0]} : "@rest"; return "@result";

It seems that the intention of this is generate a container-style tag if given arguments, and a standalone tag without arguments. The oversight is that if you call it as an object method it doesn't deal with the fact that the object is at $_[0]. So you end up with this effect:

#!/usr/bin/perl -w ################## use CGI qw/:standard/; print "foo".br()."\n"; my $q = new CGI; print "foo".$q->br()."\n"; __END__ foo<br /> Use of uninitialized value in join or string at (eval 2) line 15. foo<br></br>

That uninitialized value warning comes from the generated sub above. I think the moral is that nobody ever expected the html generating functions to be called as object methods, and it should work fine if you import them with :html and call them as regular subs.


We're not surrounded, we're in a target-rich environment!

In reply to Re: br tag in CGI.pm V2.91 by jasonk
in thread br tag in CGI.pm V2.91 by cLive ;-)

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.