in reply to RE: Automatic CODE tags
in thread Automatic CODE tags
A simple test would be something like:
(Requires clean up, and has many efficency improvements that can be made, but you get the idea. Basically if there is a line (or we could set a tolerance level...say, 4 lines?) of code that will eval, it's likely perl code. THis would also catch someone who remembered the CODE tag, but not the closing tag.if(Code-catcher-not-disabled){ foreach(@line-of_post){ if m?\</CODE\>?i{ { last; } eval { $_ }; #Actually something to do with Safe module if not $@ { $codify=1; } } }
Another option is to use one of the Perl Parsers out there to check syntax, but that involves more overhead. eval already does all the checking, and properly buried in a Safe, it shouldn't affect the exterior code at all.
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE:(2) Automatic CODE tags
by Corion (Patriarch) on Jun 20, 2000 at 20:12 UTC | |
by swiftone (Curate) on Jun 20, 2000 at 20:16 UTC | |
by Corion (Patriarch) on Jun 21, 2000 at 20:01 UTC | |
by Shendal (Hermit) on Jun 21, 2000 at 20:21 UTC | |
by swiftone (Curate) on Jun 21, 2000 at 20:40 UTC | |
by Ozymandias (Hermit) on Jun 21, 2000 at 20:45 UTC | |
| |
by Corion (Patriarch) on Jun 22, 2000 at 01:39 UTC |