[Bioperl-l] Simplifications now possible with Perl 5.6.1requirement?

Chris Fields cjfields at uiuc.edu
Tue Sep 26 14:29:11 UTC 2006


> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
> bounces at lists.open-bio.org] On Behalf Of Sendu Bala
> Sent: Tuesday, September 26, 2006 4:14 AM
> To: bioperl-l
> Subject: Re: [Bioperl-l] Simplifications now possible with Perl
> 5.6.1requirement?
> 
> Torsten Seemann wrote:
> > Now that we are confirmed that Perl 5.6.1 is a minimum requirement The
> > bioperl-live code base could be simplified somewhat. Below are some
> > major examples. Any thoughts, comments, additions ?
> >
> > -----
> > our $x; # or my $x (where appropriate)
> > # instead of
> > use vars ($x); BEGIN { $x=... };

Agreed here.  

> > -----
> > use base qw(Bio::Class);
> > # instead of
> > use vars qw(@ISA); @ISA=qw(Bio::Class);
> 
> use base arrived in 5.4? Anyway, some modules already use it, and I
> agree we all should. Worth just converting all modules over?

Yes!  Definitely agree.

> > use Test;
> > BEGIN { plan tests => 42 }
> > # instead of
> > use lib './';
> > BEGIN {
> >      eval { require Test; };
> >      if ( $@ ) { use lib 't'; }
> >      use Test;
> >      plan tests => 42;
> > }
> 
> We want to move to Test::More. When did More become a core module?

I think in perl 5.8.  I added Test::More to CVS in t/lib just in case,
(according to Michael Schwern's specifications using 't/lib' prevents CPAN
from indexing it as part of Bioperl).  

We could use either Test::More or Test::Simple, since both are included in
the CPAN Test::Simple installation (and ActivePerl PPM) and are in perl 5.8
core.

> > open my $FH, '>', $infile
> > # instead of
> > open FH, ">$infile";
> 
> The latter form has caused at least one bug, so this is worth taking
> note of.

Agreed.  Localized filehandles cut down on a lot of problems. 

> > Please contribute to http://www.bioperl.org/wiki/Bioperl_Best_Practices
> 
> I've added:
> Avoid regexps where possible: string eq > index() > =~
> 
> Of course, most people happily abuse =~ for just about everything,
> including myself ;)

Regexes are easier, agreed, but this is definitely an area where some code
could be improved. 

Another issue is 'unpacking' of @_ and the regex capture variables.  There
are a number of modules where maintainability is shot b/c someone didn't
unpack regex captures, like so:

($site, $pos1, $pos2, $strand, $score) = ($1, $2, $3, $5, $5);

Bio::Map::CytoPosition comes to mind.  At least build a queue out of them!

Christopher Fields
Postdoctoral Researcher - Switzer Lab
Dept. of Biochemistry
University of Illinois Urbana-Champaign 




More information about the Bioperl-l mailing list