[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: uninitialized vs. undefined



>I've always felt there must be a difference between

>  my @a;	# undefined
>  my @a = ();	# defined but empty

>I was slightly disappointed to find out that 5.005_63 deprecates
>defined(@a) to tell the difference.

But it doesn't do that!

    sub testit {
	my @a;
	my @b = ();

	printf "call #%d:\n", ++$count;

	if (defined @a) { print "\ta is defined\n" } 
	if (defined @b) { print "\tb is defined\n" } 

	$a[0] = $b[0] = "none";
    } 


    testit();
    testit();
    testit();

Produces:

    call #1:
    call #2:
	    a is defined
	    b is defined
    call #3:
	    a is defined
	    b is defined


--tom


Follow-Ups from:
JVromans@squirrel.nl (Johan Vromans)
References to:
JVromans@squirrel.nl (Johan Vromans)

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]