defined() confusion

From: Chris (bit_bucket5_at_hotmail.com)
Date: 12/11/03

  • Next message: Jim Gibson: "Re: Comparing values in 2 textfiles and returning the missing values"
    Date: 11 Dec 2003 10:14:32 -0800
    
    

    This seems inconsistent:
     

    #!/usr/bin/perl -w
     
    use strict;
     
    my @y;
    if(!defined(@y))
    {
      print "y undefined\n";
    }
     
    my $z = scalar(@y);
    if(!defined($z))
    {
      print "z undefined\n";
    }
     
    if(!defined(scalar(@y)))
    {
      print "scalar(\@y) not defined\n";
    }
     
     

    This prints
     
    y undefined
    scalar(@y) not defined

    So, the question is, why does

    my $z = scalar(@y);
    if(!defined($z))
     
    behave differently from
      
    if(!defined(scalar(@y)))

    ???

    Thanks,
    Chris


  • Next message: Jim Gibson: "Re: Comparing values in 2 textfiles and returning the missing values"