Wednesday, July 15, 2009

Getting STD.pm to work

In a comment to my last post, moritz suggested STD.pm would be a better check for the validity of my code as I ported it from Perl 5 to Perl 6. I duly set out to figure out how to do this -- and since I didn't find any hint of how to do it with a Google search, I'll document it here in hopes it helps someone else.

The legendary TimToady pointed me in the right direction. First, STD.pm and the scripts for using it live in the Pugs repository. I got http://svn.pugscode.org/pugs, though it may be possible to just get the src/perl6 directory tree, as that is the one we are interested in.

Once you have that src/perl6 directory, cd to it. You need to make to get it ready to use. Unfortunately, it is hardcoded to assume Perl 5.10 is available in /usr/local/bin/perl. If, like me, you only have 5.10 installed as a local user, you will need to go through the code and replace that path with the path to your Perl 5.10. (This is a great application for a quick Perl script.) You also need to have Moose and YAML::Syck installed. (I should thank moritz and PerlJam for helping me with getting this directory prepped to work.)

If you get that all set up and execute make and it doesn't return any errors, then you should have a working STD.pm! The tryfile command will try to parse your Perl 6 file carefully and provide sensible error messages.

4 comments:

  1. You're not going to get away that easily ;-) - you also have to tell us if the output from STD.pm was actually helpful.

    ReplyDelete
  2. Well, my first try produced a beautiful error message: Obsolete use of C-style "for (;;)" loop; in Perl 6 please use "loop (;;)" instead. I already knew that, but (as I pointed out in my last post) Rakudo accepted it without complaint. (Of course, I knew that one already, so it's not particularly helpful, but it is quite impressive -- enough so to probably push me over the edge to building Perl 5.10 on my MacBook Pro.)

    Unfortunately, I had to get to paying work in two senses of the word: I've spent the last five hours since getting that working paying bills and doing the quarterly tax forms.

    ReplyDelete
  3. @SF

    Did u get Padre Perl 6 plugin working on your Mac?

    If so, you would have found all that you have mentioned inside it along with quick fixes for that error and more. STD.pm is used to parse and highlight Perl 6 files in Padre and these nice error messages are collected in an error list pane.

    P.S. When Rakudo catches up, we will be able to run STD via Rakudo. Right now, STD.pm is dependent on Perl 5.10 features namely the regex engine and state variables. I know that it is a bit slow, but it works :)

    ReplyDelete
  4. @Ahmad, I've not gotten it installed yet. But since I just installed 5.10 to get STD.pm working on my laptop, I'll probably install Padre Perl 6 very soon as well.

    @moritz, I should add that I've now used STD.pm to help convert this Perl 5 script to Perl 6 with great success -- though the script still has a few glitches that need to be worked out.

    ReplyDelete