http://qs1969.pair.com?node_id=49061


in reply to Re (tilly) 1: Supersplit
in thread Supersplit

If you are a module, there is no need to do initializations in a BEGIN block.

Maybe you haven't found any but I certainly have. They aren't easy to run into but I still find it a valuable habit. Leaving a potentially large window for a race condition to fit into isn't my idea of a good programming technique. I suspect that future features of Perl will make this even more important to avoid.

Along those lines, I'd use base qw(Exporter) myself, though I look forward to just being able to dispatch &import and avoid the sledgehammer of inheritance. (:

I consider qr// to be new enough of a feature that if I were to use it in a module I would make it optional:

BEGIN { my $sub; if( $] < 5.005 ) { $sub= 'return $_[0]'; } else { $sub= 'return qr/$_[0]/'; } eval "sub _qr { $sub }; 1" or die $@; } # ... _split($text, map {_qr($_)} @_);
(untested, though).

        - tye (but my friends call me "Tye")