RE: [code-review] WebService::Validator::HTML::W3C
"Hodges, Paul" <Paul.Hodges-zv7RHi0Am8a1Z/[email protected]> Fri, 14 Nov 2003 13:24:22 -0600
| Newsgroups | gmane.comp.lang.perl.code-review-ladder |
|---|---|
| Message-ID | <9C375DDD9B669243A2D78FCD607E894003E4FCFC@bremo-jg> |
> From: Tony Bowden [mailto:[email protected]] > On Fri, Nov 14, 2003 at 05:01:20PM +0000, Struan Donald wrote: > > Any thoughts/improvements/whatever on the attached? > > if ( $v->validate("http://www.example.com/") ) { > if ( $v->valid ) { > printf ("%s is a valid website\n", $v->uri); > } else { > printf ("%s is not a valid website\n", $v->uri); > foreach $error ( $v->errors ) { > printf("%s at line %n\n", $error->{description}, > $error->{line_no}); > } > } > } > > As well as the formatting of this being a little wonky, I would also > find this misleading as a first time user. Your example output of "a > valid website" implies that it's going to crawl and validate the > entire site, when it appears to only do a single URI. How about if ( $v->validate("http://www.example.com/") ) { print $v->uri, $v->valid ? " validates\n" : " does not validate\n"; print $_->{description}, " at line ", $_->{line_no}, "\n" for $v->errors; } which avoids unnecessary printf's and code duplication and wonkiness and typing? It does get a little dense, though, and I didn't test it....caveat emptor. ***** "The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.61"