[Bioperl-l] $_ assignment question

simon andrews (BI) simon.andrews at bbsrc.ac.uk
Fri Aug 1 03:52:08 EDT 2003


 
> On Thu  16:08, Paul Edlefsen wrote:
> > My understanding has been that Bio::SeqIO->new(..) will 
> > surely use the correct method, while new Bio::SeqIO might 
> > use the new(..) method from the class that the code appears 
> > in, which would be incorrect.  Have I misunderstood the issue?
> > 

> From: Josh Lauricha 
> I've always been under the impression they are interchangable. 
> If they aren't, what would be an example of the wrong function 
> being called?

#!/usr/bin/perl -w
use strict;
use Bio::SeqIO;

my $name = 'Bio::SeqIO';

sub new {
  return ("Oops!\n");
}


my $indirect = new $name;
print "INDIRECT: $indirect\n";

my $direct = $name -> new();
print "DIRECT: $direct\n";


More information about the Bioperl-l mailing list