[Bioperl-l] $_ assignment question

Jason Stajich jason at cgt.duhs.duke.edu
Thu Jul 31 10:15:53 EDT 2003

> This might be usually harmless, but when a caller is using $_ then
> trouble can occur.
> I ask as there seems to be a lot of use of the idioms:
>     return unless $_ = shift;
> and:
>     while ($_=$self->_readline()) {
>     }
> Is there some valid Bioperl reason that local can't be called on $_
> before the assignment.
> Usually it's easy to see why it's been done, but the problem comes with
> some of the while() loops that use the 2nd idiom and have huge amounts
> of code in them, including many method calls which could depend on $_
> being set before being called (even though this would be a violation of
> data hiding) and I'm too Lazy to check them without first asking.
No reason not to change it - local($_) should be done.  If there are
problems with someone being lazy enough to actually depend on $_ being
set by a called method hopefully the tests will be good enough to pick
them up.

Code audit & cleanup is enthusiastically welcomed.  Lots of things have
been written by a pretty wide range of perl experience so anyone brave
enough to start doing some systematic cleanups gets major beers points

If you are going to be making a ton of changes I would rather they go to
CVS directly than having to juggle hundreds of patch requests.  Give us a
sense of what the magnitude of bug fixes will be if/when you dive in.

> Also, is there any reason why indirect invocation of methods is being
> used in some places, according to Damian Conway [1], this is a bad idea.

Java/C++ trained programmers with bad habits...

> So are there any Bioperl specific reasons why its being used?
> Cheers
> [1] Object Oriented Perl, Damian Conway - p98

Jason Stajich
Duke University
jason at cgt.mc.duke.edu

More information about the Bioperl-l mailing list