How to Test the Method Keyword Patch

| 1 Comment

Suppose you want to see how a hypothetical Perl 5.16 with a method keyword might work. Reading the patch to add method to Perl 5 isn't as fun as using it yourself.

If you're an old hand at patching and building Perl 5, you already know what to do. That leaves about a million of the rest of us.

First, check out a recent bleadperl from Git. Within that directory, check out revision 8bdb331 (as it's the basis of the patch). You can use later revisions, but you may have to massage the patch yourself:

$ git checkoout 8bdb331

Now download the method patch and apply it:

$ patch -p1 < 0001-Added-use-feature-method-and-tests.patch

Everything should apply cleanly. Now you need to configure Perl:

$ sh Configure -de -Dusedevel -Dprefix=$PERLBREW_ROOT/perls/perl-5.13-method

If you don't use perlbrew, you should. With this configuration you can install bleadperl with this patch as if it were a released Perl 5, at least as perlbrew sees it. Change the value of -Dprefix to match your preferred installation directory. After a few moments, you can regenerate the parser and other generated files, then build, test, and install the new Perl yourself:

$ make regen regen_perly
$ make test
$ make install

If you have trouble building or installing bleadperl, read the included INSTALL file. I cannot provide technical support here; the usual Perl 5 support channels apply (especially if you also have trouble building, testing, or installing bleadperl without this patch).

Then you can use perlbrew to switch to the new Perl 5 (perlbrew use perl-5.13-method or perlbrew switch perl-5.13-method) and test it with your favorite code.

Update: improved instructions per oylenshpeegul's comments.

1 Comment

I had no trouble building and installing bleadperl, but when I add the patch (which seems to go smoothly), it won't compile.

`sh cflags "optimize='-O2'" toke.o` toke.c
CCCMD = cc -DPERL_CORE -c -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -std=c89 -O2 -Wall -ansi -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wc++-compat -Wwrite-strings
toke.c: In function ‘Perl_yylex’:
toke.c:7459: error: ‘KEY_method’ undeclared (first use in this function)
toke.c:7459: error: (Each undeclared identifier is reported only once
toke.c:7459: error: for each function it appears in.)
toke.c:7464: warning: unused variable ‘key’
make: *** [toke.o] Error 1

Also, I don't think there is a "co" command in git (though it's often aliased to "checkout"... or sometimes "commit"). You probably want to change that to "git checkout 8bdb331" in a blog entry like this.

There is a $PERLBREW_ROOT environment variable, so you could write

sh Configure -de -Dusedevel -Dprefix=$PERLBREW_ROOT/perls/perl-5.13-method

for that line.

Modern Perl: The Book

cover image for Modern Perl: the book

The best Perl Programmers read Modern Perl: The Book.

sponsored by the How to Make a Smoothie guide



About this Entry

This page contains a single entry by chromatic published on February 4, 2011 10:39 AM.

Politely Suggesting Improvements was the previous entry in this blog.

When the Dependency Problem is Core Language Problem is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by the Perl programming language

what is programming?