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

Francisco J. Ossandón fossandonc at hotmail.com
Mon Mar 3 21:51:08 UTC 2014


Hello,
I've finished to eliminate as much $_ as I could from Bio::Root.
Currently some $_ still remain inside grep() and map() blocks (where I think they will not cause trouble), and there others which I was not sure how to proceed (mainly in Build.pm) and I could not find code or tests that run through those lines to experiment with them (like: "return $_ = { map {$_,1} @{$self->rscan_dir('scripts', qr/\.PLS$|\.pl$/)} };"). Could somebody try to squash the remaining $_ in Root modules??

On the original Carne's code showing the problem, it still shows trouble. "Root::IO.pm" now only have a $_ inside a grep/map line, so the next step would be to check SeqIO::genbank, and much later go over the rest of the modules. It would be great if somebody can go on checking SeqIO::genbank, since my job workload has increased considerably. =(

Cheers,

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