Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Automatic CODE-tag creation (Prototype)

by Corion (Pope)
on Jun 21, 2000 at 20:01 UTC ( #19263=note: print w/ replies, xml ) Need Help??


in reply to RE:(4) Automatic CODE tags
in thread Automatic CODE tags

I played around with the idea a bit yesterday night (the nights are really hot this time in .de :)), and here's a prototype that does some good formatting on my coding style. I don't know how well it works for other coding styles, and the implementation is a bit crude ... I couldn't get your elegant idea of "most single lines should compile" to work for me, so I resorted mostly to static REs - quite unelegant, as any such list is bound to be incomplete ...

Anyway, if anybody wants to have a look at how a heuristic markup could be done, here's the code (the code is still a bit confused about CODE and PRE tags, but you should get the intention ...) :

Update :D'oh - as soon as I go offline, I see many problems with the code. So here's an updated version ... Hmm - and I follow the suggestion and put the code into the Code Catacombs instead of posting it here ... The Code


Comment on Automatic CODE-tag creation (Prototype)
RE: Automatic CODE-tag creation (Prototype)
by Shendal (Hermit) on Jun 21, 2000 at 20:21 UTC
    This is nice, but don't you think it really belongs in the Code Catacombs?

RE: Automatic CODE-tag creation (Prototype)
by swiftone (Curate) on Jun 21, 2000 at 20:40 UTC
    The Perl Gods have said that the Perl interpreter is the best way to interpret Perl, so I'm still thinking that something that works with that would work better. After some testing though, I've discovered that the Safe Module will not do what I wanted. What we really need is the perl -c command function. I know nothing about the guts of perl, but there should be someway to access this. Do any of the Perl Gods have ideas?
      What about something as simple as calling the perl interpreter with a system call? Something as simple as this:
      qx {perl -c $function_to_be_executed}
      It's clumsy, yes, but it should work.

      - Ozymandias

        Overhead of calling a system process. If we're doing this for every post, PM would grind to a halt. The function is already loaded in memory, we just have to learn how to call it.

        I'll work up some demo code like this, but without that efficiency, it isn't worth inserting.

      I also know that the only thing that can determine if some sequence of characters is valid Perl is Perl itself, but the main idea is to have some heuristics to format posts by people who don't know how to use the site ...

      This is not thought as a general Perl formatter, but only for quick weeding of AM posts.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://19263]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (14)
As of 2014-12-22 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (118 votes), past polls