[Bioperl-l] Bio::SeqIO modifies $_

Francisco J. Ossandón fossandonc at hotmail.com
Sat Mar 8 13:50:25 UTC 2014


Yesterday I went through all the Genbank module and eliminated all use of '$_' plus extra cleaning (https://github.com/bioperl/bioperl-live/commit/41a54839d37d8c87cb2d5b21bf160c979eaf7f34). Now the example code from Carne works as expected. =)

The same probably have to be done with the rest of the modules, but that will take some time and more hands will be needed... =(

Cheers and have a good weekend,

Francisco J. Ossandon

-----Mensaje original-----
De: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-bounces at lists.open-bio.org] En nombre de Leon Timmermans
Enviado el: domingo, 02 de febrero de 2014 20:07
Para: Francisco J. Ossandón
CC: Carnë Draug; <bioperl-l at bioperl.org>
Asunto: Re: [Bioperl-l] Bio::SeqIO modifies $_

On Tue, Jan 28, 2014 at 9:21 PM, Francisco J. Ossandón < fossandonc at hotmail.com> wrote:

> Hi,
> One of things that have always bugged me a little about Bioperl code 
> is that it extensively use "$_", when parsing blast for example:
> * "while ( defined( $_ = $self->_readline ) ) {", instead of "while ( 
> defined( my $line = $self->_readline ) ) {"
> * elsif(/^Reference:\s+(.*)$/) {
> * etc.
>
> For now I have been following the current style of keeping $_ when 
> making fixes, but in my own scripts I always create named scalars 
> which also avoids confusion ("foreach my $element ()", "while (my $bar 
> =)", etc.).
>
> I would vote for extensive removal of $_ use, except in cases where 
> really needed (maybe longer code, but also more clarity), but I will 
> not have the free time needed to do it for several weeks.
>

$_ is not necessarily a bad idea as long as it is localized properly; either by «local $_ = ...» or «for (...) {...}». But I agree most of the time it should be avoided.

Leon

_______________________________________________
Bioperl-l mailing list
Bioperl-l at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/bioperl-l





More information about the Bioperl-l mailing list