Sunday, 16 September 2012

perl 5.14 and up will break some of well known programs! Think twice (test thrice) before use it!

Seems that at some point someone thought that a qw() in a for loop should be surrounded by parents (qw()).
Lines like
$  perl -e 'foreach $x qw(1 2 3){print $x}'
Use of qw(...) as parentheses is deprecated at -e line 1.
are not permitted any longer. People has revealed against this and patches were proposed, but perl 5.16 still does not permit it. Some people say that this was a 'feature' of the parser not an intended behaviour (see comments in Reini's post).
In my case I switched to perl 5.14 and VCFtools was not working any more. At least I discovered it testing the test suit. 20 test failed all with the same error:
[..]
not ok 30 - Testing vcf-consensus .. perl -I../perl/ -MVcf ../perl/vcf-consensus  consensus.vcf.gz < consensus.fa
#   Failed test 'Testing vcf-consensus .. perl -I../perl/ -MVcf ../perl/vcf-consensus  consensus.vcf.gz < consensus.fa'
#   at test.t line 418.
#     Structures begin differing at:
#          $got->[0] = 'Use of qw(...) as parentheses is deprecated at ../perl//Vcf.pm line 1622.
#     '
#     $expected->[0] = '>1:1-500
[...]
I am lucky to be using perlbrew so I can change quickly from one version of perl to another (not so lucky that I need to reinstall a lot of CPAN modules.)

2 comments:

Anonymous said...

You blame Perl and its maintainers? Mind-boggling. I blame the VCFtools maintainers for being so lazy and not keeping up with the Perl releases! This requires literally no effort: if they had put this on CPAN like a normal person, automatic smoking would have revealed this bug already in September 2010 when 5.13.5 came out.

Pablo Marin-Garcia said...

No, I am not blaming Perl, nor VCFtools (they fix that in the svn but not yet in the stable version). I only say that before updating Perl you need to test that all things go OK. And wanted also stating the importance to have tests (as VCFtools have) even if you are not putting your modules in CPAN.