Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^2: perltidy in PM posts (read blues)

by tye (Sage)
on Nov 23, 2011 at 07:45 UTC ( #939616=note: print w/replies, xml ) Need Help??

in reply to Re: perltidy in PM posts
in thread perltidy in PM posts

Not to criticize you, ansh batra, but just to, I hope, inform you a little and perhaps amuse you, simply because I enjoyed your comment about newbies the most of the comments so far... :)

Yes, syntax highlighting certainly makes things easier to understand for newbies. Consider perlop. This excerpt would just be so much harder to understand if I hadn't copied the "syntax highlighting" from

Options (specified by the following modifiers) are:

   1.   m   Treat string as multiple lines.
   2.       s       Treat string as single line. (Make . match a newline)
   3.   i   Do case-insensitive pattern matching.
   4.   x   Use extended regular expressions.
   5.   p   When matching preserve a copy of the matched string so
   6.       that ${^PREMATCH}, ${^MATCH}, ${^POSTMATCH} will be defined.
   7.   o   Compile pattern only once.
   8.   l   Use the locale
   9.   u   Use Unicode rules
  10.   a   Use ASCII for \d, \s, \w; specifying two a's further restricts
  11.               /i  matching so that no ASCII character will match a non-ASCII
  12.               one
  13.       d   Use Unicode or native charset, as in 5.12 and earlier

If a precompiled pattern is embedded in a larger pattern then the effect of "msixpluad" will be propagated appropriately. The effect the "o" modifier has is not propagated, being restricted to those patterns explicitly using it.

The fact that the only text within sight that is blue is the three '$' characters (I'm sorry, I should have made that dollar sign that I just typed blue; I'm sure I've confused most of the newbies now) clearly indicates something that newbies would not have understood without the clarion indicator of "blueness" (every newbie knows what blue means in that context; that goes without saying).

But that pales in comparison to the boundless clarity that is only possible by having the red parts be red.

The indentation getting a bit wonky in a couple of places is such a small price to pay for these huge leaps in clarity of the text.

On a serious note, if you want to know about syntax highlighting at PerlMonks, then there are several facilities provided for searching for such things.

I'm sure somebody will soon post links to no small number of previous discussions. (Ah, yes, as I expected, this happened before I even finished composing this.)

In the mean time, I'll summarize: If you want colors assigned to things based on some algorithm that clearly fails when it tries to parse some Perl code and fails even more interestingly when it tries to parse things that aren't Perl code as if they were Perl code (or if you want to go the stackoverflow route of assigning colors based on some vague feel of "bits of syntax that are somewhat common to more than one programming language"), then you need to pick the poison of your choice and impose it upon yourself. And that isn't particularly hard. I'm sure some of the linked threads even provide instructions (but I didn't check).

Though, if anyone still thinks that either of those approaches won't often decrease clarity, then I suspect that mostly means that they don't pay all that much attention much of the time. (:

BTW, the perldoc example is just something I stumbled upon last week. I wasn't even looking for examples of "syntax highlighting gone wrong". I run into those often enough without looking for them and that's even though I never use syntax highlighting by choice.

- tye        

  • Comment on Re^2: perltidy in PM posts (read blues)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://939616]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-03-23 03:30 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (287 votes). Check out past polls.