Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
japhy, I like what this does, but it strikes me as similar to the English module: a nice idea that few, if any, use. However, it might be justifiable the way CGI.pm's HTML methods are: as a way of validating the syntax of the output.

For example, many people object to the following in a CGI program:

print $q->Tr( { -bgcolor => $bgcolor[ $toggle->() ] }, $q->td( $key . "  " ), $q->td( $q->pre( $data ) );
Why don't I just use HTML with a here document or a template? In this case, the value of the CGI.pm HTML functions is apparent:
  • I can't mis-nest tags.
  • I can't forget to close a tag.
  • I get a handy "syntax check" of HTML code that ordinarily wouldn't be checked.
The last item isn't as much of an issue here, but the first two could be. I think that if it's constructed properly, invalid constructs may be more glaring and/or harder to construct. For example, how many times have we seen regexes like the following?
$somevar =~ /^[\d|\w|\*]+$/; # Bad regex, no biscuit.
With your syntax, a person could more naturally write the following:
$match_stuff = form_REx( start, # ^ class("\d\w*"), # [\d|\w|\*] <- still bad! one_or_more, # + end # $ );
And you could output /^[\w*]+$/ for the regex (assuming that you check for existence of overlapping metacharacters). This would help with regex syntax problems and could cut down on some of the more insidious logic problems that newbies (and Ovid) are prone to.

Cheers,
Ovid

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


In reply to (Ovid) Re: Regex Learning Tool by Ovid
in thread Regex Learning Tool by japhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-23 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found