README
1
2 -=* Syntax::Highlight::Perl::Improved v1.01 *=-
3
4Please note: Right now, this is simply a bug-fixed version of Cory John's
5original Syntax::Highlight::Perl, since it appears that he is no longer
6maintaining the module. This may eventually change. (See the ChangeLog for
7more information.) --David C.Y. Liu
8
9This is a module for marking up Perl code files for presentation,
10printing, or publication. This markup can be made up of any user-
11specified strings and can include anything ranging from HTML/XML to
12PostScript formatting codes to ANSI escape sequences to abstract,
13binary-data markups.
14
15The current version of the module is suited best to one-shot, full
16document processing that is not exceedingly time-critical. No attempts
17have yet been made to optimize the formatting routines. It is not
18inordinately slow but there is a small-but-noticeable delay when
19rendering anything but the most simple of code files. You can try
20out the included command-line viewing script (viewperl) to see how
21it runs on your system. The delay is not usually noticeable in CGI
22scripts, as it is usually overshadowed by the latency of the internet.
23
24The other main reason that the current version of the module is not
25well suited for time-critical, repeated tasks (an example of such
26a task might be syntax highlighting in an editor, where the active
27line should be re-processed after every keystroke, and possibly
28following lines as well) is that it has no method of "back-tracking,"
29or revising a token that has already been formatted without reformatting
30the entire string. Using our example of a syntax highlighting editor,
31this means that we would have to re-process the entire document every
32time the user presses a key. This would introduce a prohibitive
33delay in the response time of the program. (A way around this would
34be to save a "state-copy" of the document at the point just before
35the active line but this requires a fast state-copying routine, and
36the only current method for state-copying -- calling the new()
37method on an existing object -- uses string eval (a la Data::Dumper)
38to perform the necessary deep-copy of the data structure. This may
39be addressed in the next version.)
40
41The lack of a back-tracking feature also puts a limitation on the
42module's ability to handle certain Perl constructs. Two good examples
43of this type of construct are the x and e modifiers to certain Regular
44Expression operators. We cannot tell before we encounter them that
45we should be formatting the Regular Expression differently than usual,
46and yet there may be several lines of code that should be formatted
47specially before we get to them! I cannot, as of yet, think of a
48good way to accomplish this, or even if it's possible. If you can
49think of a way to do it, please let me know.
50
51
52 -=* VIEWPERL *=-
53
54A useful utility that uses the module has been included. This utility
55allows you to view Perl programs or modules quickly from the command
56line, fully syntax highlighted. (Note that this utility uses ANSI
57color escape sequences, so your terminal must support them.)
58
59To use viewperl, just make it executable and place it somewhere on
60your path. Then just type `viewperl FILE' or `viewperl -m MODULE',
61where FILE is the name of a file or MODULE is the name of a module
62installed on your system (in the form you would `use' it in your
63script; eg: Syntax::Highlight::Perl). You can also pipe or redirect
64data into viewperl. Typing `viewperl' with no file names causes it
65to read from the standard input. You can also use the -c option
66to specify a string of code to format from the command line.
67
68You can turn on line numbering with the -l option, or you can hide
69any inline POD using the -P option. Type `viewperl --help' for a
70list of all the options available, as well as a description of each.
71