Lesson of the day: Readonly, Exporter, and subroutine sigils

elliot on 2007-09-07T22:04:30

They don't get along.

As of the recent 1.07 release, Perl::Critic, has started using Readonly to be more more self-compliant with Perl Best Practices. We had been avoiding use of constant for the reasons described in the book, but had not been willing to add the Readonly dependency until now.

The Perl::Critic coding standard has been to use sigils for subroutines in @EXPORT_OK, etc. and import lists, but Exporter treats them as optional. And, in fact, there's code that strips them off (line 47 in v5.58). I haven't figured out the commonality, but in a few environments, this fails spectacularly. Once we removed the subroutine sigils from everywhere, the problems have gone.

Explicitness: 0, Keyboard laziness: 1.


How to reproduce?

ferreira on 2007-09-08T17:53:48

It would be helpful if you explain how to reproduce the failures you have seen. A test script or a short recipe would be nice.

Re:How to reproduce?

elliot on 2007-09-17T01:25:28

This problem was been found on various Linux environments (e.g. http://www.nntp.perl.org/group/perl.cpan.testers/2007/09/msg606459.html) when testing Perl::Critic; what is common between them other than Linux I haven't identified. Since I don't have a Linux environment currently, I haven't traced down the exact circumstances. Where the failure occurred was not consistent between different environments, so I ended up removing all use of subroutine sigils in Perl::Critic 1.075_001 and this fixed the problem. If you want to play with this yourself, grab Perl::Critic 1.074 and see whether you can reproduce it.