Perl 5.10: December 2007 Archives

Make vim support Perl 5.10

| | Comments (1)

The new say function isn't supported by the perl.vim file that ships with vim. Nick Hibma, the maintainer, tells me it will be updated in the next version of vim. In the meantime, you can hack your local vim files by adding the following line to your ~/.vim/syntax/perl.vim file:

syn keyword perlStatementFiledesc
    \ binmode close closedir eof fileno getc
    \ lstat print printf readdir readline readpipe rewinddir
    \ say select stat tell telldir write
    \ nextgroup=perlFiledescStatementNocomma skipwhite

Even if you haven't upgraded to Perl 5.10, you can use Jim Keenan's Perl6::Say module to add the say function.

My baby, ack, broke under Perl 5.10.0, because of a fix in regex behavior that I had been using unknowingly. See, I had always used my regex objects like this:

my $re = qr/^blah blah/;
if ( $string =~ /$re/sm )...

when I should have been using it like this:

my $re = qr/^blah blah/sm;
if ( $string =~ /$re/ )...

The bug in 5.8.x is that the /$re/sm would incorrectly apply the /sm modifiers to $re. This made the code happen to work, but for the wrong reason. What was especially tricky about finding my bug was that in 5.10.0, the call to /$re/sm ignores the /sm, but doesn't tell you that.

After some back and forth on p5p, a patch was submitted that gave the warning about the ignored /sm flags, but alas, Perl 5.10 was already out. It wouldn't have been so bad if it hadn't been the day AFTER it was released.

So, lesson learned: Test your code against new release candidates of Perl, both for your code's sake, AND for Perl's sake.

And y'know, now that I think of it, this is probably a great policy for Perl::Critic just waiting to happen. I wonder how many other people are doing their regexes the wrong way, too.

About this Archive

This page is a archive of entries in the Perl 5.10 category from December 2007.

Perl 5.10: January 2008 is the next archive.

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

Other Perl Sites

Other Swell Blogs

  • geek2geek: An ongoing analysis of how geeks communicate, how we fail and how to fix it.

Perl 5.10: December 2007: Monthly Archives