in reply to Seeker of Perl Code Review

Well, I tried the following code:
my $index = $#array; #Doesn't treat array as comment my $txt = "$index and something"; #Highlights $index! print OUT "$txt->test()"; #Doesn't highlight ->test() s/ (\d+ #test \w{1,3}) (\s) / $2 ? "yes" : $1 /ex; #Recognizes s///ex as the regex
And the highlighted code looked OK. So you did a better job than emacs/jed (dunno about vim). Only thing is, it doesn't recognize the code within the regex, and also not the comments within the extended regex. But maybe you hit the ceiling here, as merlyn states that "only perl can parse perl code" (paraphrased).

The highlighted syntax looks pretty, especially in color on white. Methinks your only competitor is a2ps, you can find it on Outside links.

Nice job!

Jeroen
"We are not alone"(FZ)

Replies are listed 'Best First'.
(bbfu) (tested code) Re: Re: Seeker of Perl Code Review
by bbfu (Curate) on Mar 23, 2001 at 02:49 UTC

    Ah, I'm glad someone's really putting it to the test. :) And yes, it does do better than VIM. :-p (You should see VIM choke on the relatively simple: qr ( one ( two ) three )x;!)

    Regular Expressions are one of the weak points of the module. It's even listed under KNOWN ISSUES or LIMITATIONS (or at the mirror) in the documentation. I may add support for regexp-special characters later, and maybe even set it up to handle the /e option. The big problem with the /e option is that it requires back-tracking (see my recent reply).

    I tried to show off, in the Test file, some of the tricky constructs that the formatter handled correctly. Especially that funky here-doc stuff at the bottom. :) Note that VIM doesn't even handle formats at all. All in all, I've tried to make it as true to Perl as I could (without actually parsing the code!). Considering I just shatter the string with a heavy regexp (or 10) and then walk through the pieces, I'm surpised I got it working this well! :D

    Thanks for the tip on a2ps! I originally started writing this module because I didn't know of anything that would highlight Perl code for presentation-or-printing. I wanted to be able to really show off my code on the web so I started working.

    I looked through the home page for a2ps and it looks nice. Very versatile as far as languages it handles, though I think that limiting it to PostScript output makes it not as good for my orignal purpose (of converting code to HTML). Do you know of a PS to HTML filter? I certainly never plan to extend my formatter to handle languages other than Perl (people use languages other than Perl???) so I think a2ps will always beat me out in that respect. :) I didn't install it to try it out so I don't know how well it handles some of the more esoteric constructs of Perl. It certianly looks powerful enough to do a good job!

    Well, thanks again for your reply, and let me know if you get a chance to delve into the depths of the module and can offer any suggestions for improvement!

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.

      Converting PostScript to anything else is rather hard. To see why you should stop thinking of a PostScript file as a document but instead think of it as a programming language which is capable of giving a printing device instructions that will cause it to print out the document.

      Yes, if you send a PostScript printer the correct document rather than printing it will instead install a stealth backdoor that contacts someone and tells them that their latest victim is waiting. I forget whether the default password on HP printers was "OOOO" or "OOOOOO", but it is fairly simple to guess. And, as you can imagine, most people don't realize that their printer is a fairly capable reprogrammable computer, with an operating system (written in PostScript), full networking capabilities, etc.

      I will give it a better look, but when I have some time at hand. It might take a while.

      As for ps2html: Hardly. Postscript is more an end-language, something that you don't like to convert to text-like things. You'd better think like ps2pdf (exists), as pdf is a more or less 'accepted' web-standard.

      Later on I saw you remarks on that your script only works line-wise. That makes sense, and I don't think that you can except this kind of script to detect all perl-oddities.

      Cheers,

      Jeroen
      "We are not alone"(FZ)

Re: Re: Seeker of Perl Code Review
by petral (Curate) on Mar 24, 2001 at 07:49 UTC
    Just for the record, emacs in cperl-mode (by Ilya Zakharevich) got all of these except the comment in the x'd regex.

    p