in reply to Predeclaration
my @x; print 'my @x;',"\n"; &checkdef; @x = (); print '@x = ();',"\n"; &checkdef; @x = (1); print '@x = (1);',"\n"; &checkdef; @x = (); print '@x = ();',"\n"; &checkdef; undef @x; print 'undef @x;',"\n"; &checkdef; @x = (); print '@x = ();',"\n"; &checkdef; sub checkdef { if (defined (@x)) { print "\@x is defined\n" } else { print "\@x is undefined\n" } } __OUTPUT__ my @x; @x is undefined @x = (); @x is undefined @x = (1); @x is defined @x = (); @x is defined undef @x; @x is undefined @x = (); @x is undefined
Is anyone else surprised by the results?
--
flounder
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Predeclaration
by Abigail-II (Bishop) on Jul 16, 2002 at 14:49 UTC | |
by flounder99 (Friar) on Jul 16, 2002 at 17:39 UTC |