[Bioperl-l] perl 5.6

James Gilbert jgrg@sanger.ac.uk
Wed, 16 Aug 2000 14:09:12 +0100 (BST)


Jason,

Yes, these are identical.  I guess defined(@array)
was useful in the Perl 4 days, when you could use
it to check if @array had been created yet.

I think people tend to over use defined().  It's
only really needed if the value you are testing
can validly be zero or empty string.  I often see
statements like:

  if (! defined($i) || $i == 0) {

when a simple

  unless ($i) {

would do.

	James


On Mon, 14 Aug 2000, Jason Stajich wrote:

> Aren't these the same?
> 
>  if( ! defined(@a) || (scalar @a) == 0) 
> 
>  if( ! @a ) 
> 
> perl 5.6.0 is complaining
> "defined(@array) is deprecated "
> 
> 
> -jason
> 
> Jason Stajich
> jason@chg.mc.duke.edu
> http://galton.mc.duke.edu/~jason/
> (919)684-1806 (office) 
> (919)684-2275 (fax) 
> Center for Human Genetics - Duke University Medical Center
> http://wwwchg.mc.duke.edu/ 
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
> 

James G.R. Gilbert
The Sanger Centre
Wellcome Trust Genome Campus
Hinxton
Cambridge                        Tel: 01223 494906
CB10 1SA                         Fax: 01223 494919