case OP_PADAV:
case OP_AASSIGN: /* Is this a good idea? */
Perl_warner(aTHX_ WARN_DEPRECATED,
- "defined(@array) is deprecated (and not really meaningful)");
+ "defined(@array) is deprecated");
Perl_warner(aTHX_ WARN_DEPRECATED,
"(Maybe you should just omit the defined()?)\n");
break;
case OP_RV2HV:
case OP_PADHV:
Perl_warner(aTHX_ WARN_DEPRECATED,
- "defined(%hash) is deprecated (and not really meaningful)");
+ "defined(%hash) is deprecated");
Perl_warner(aTHX_ WARN_DEPRECATED,
"(Maybe you should just omit the defined()?)\n");
break;
(W) You used the C<open(FH, "| command")> or C<open(FH, "command |")>
construction, but the command was missing or blank.
-=item defined(@array) is deprecated (and not really meaningful)
+=item defined(@array) is deprecated
(D) defined() is not usually useful on arrays because it checks for an
undefined I<scalar> value. If you want to see if the array is empty,
just use C<if (@array) { # not empty }> for example.
-=item defined(%hash) is deprecated (and not really meaningful)
+=item defined(%hash) is deprecated
(D) defined() is not usually useful on hashes because it checks for an
undefined I<scalar> value. If you want to see if the hash is empty,
recursion, unless you're writing strange benchmark programs, in which
case it indicates something else.
-=item defined(@array) is deprecated (and not really meaningful)
+=item defined(@array) is deprecated
(D) defined() is not usually useful on arrays because it checks for an
undefined I<scalar> value. If you want to see if the array is empty,
just use C<if (@array) { # not empty }> for example.
-=item defined(%hash) is deprecated (and not really meaningful)
+=item defined(%hash) is deprecated
(D) defined() is not usually useful on hashes because it checks for an
undefined I<scalar> value. If you want to see if the hash is empty,
returns C<undef> when its argument is an empty array, I<or> when the
element to return happens to be C<undef>.
-You may also use C<defined> to check whether a subroutine exists, by
-saying C<defined &func> without parentheses. On the other hand, use
-of C<defined> upon aggregates (hashes and arrays) is not guaranteed to
-produce intuitive results, and should probably be avoided.
+You may also use C<defined(&func)> to check whether subroutine C<&func>
+has ever been defined. The return value is unaffected by any forward
+declarations of C<&foo>.
+
+Use of C<defined> on aggregates (hashes and arrays) is deprecated. It
+used to report whether memory for that aggregate has ever been
+allocated. This behavior may disappear in future versions of Perl.
+You should instead use a simple test for size:
+
+ if (@an_array) { print "has array elements\n" }
+ if (%a_hash) { print "has hash members\n" }
When used on a hash element, it tells you whether the value is defined,
not whether the key exists in the hash. Use L</exists> for the latter
you're trying to do. At other times, a simple comparison to C<0> or C<""> is
what you want.
-Use of C<defined> on aggregates (hashes and arrays) is deprecated. It
-used to report whether memory for that aggregate has ever been
-allocated. This behavior may disappear in future versions of Perl.
-You should instead use a simple test for size:
-
- if (@an_array) { print "has array elements\n" }
- if (%a_hash) { print "has hash members\n" }
-
See also L</undef>, L</exists>, L</ref>.
=item delete EXPR
(Maybe you meant system() when you said exec()?
exec "true" ; my $a
- defined(@array) is deprecated (and not really meaningful)
+ defined(@array) is deprecated
(Maybe you should just omit the defined()?)
defined @a ;
my @a ; defined @a ;
defined (@a = (1,2,3)) ;
- defined(%hash) is deprecated (and not really meaningful)
+ defined(%hash) is deprecated
(Maybe you should just omit the defined()?)
defined %h ;
my %h ; defined %h ;
use warning 'deprecated' ;
defined(@a);
EXPECT
-defined(@array) is deprecated (and not really meaningful) at - line 3.
+defined(@array) is deprecated at - line 3.
(Maybe you should just omit the defined()?)
########
# op.c
use warning 'deprecated' ;
my @a; defined(@a);
EXPECT
-defined(@array) is deprecated (and not really meaningful) at - line 3.
+defined(@array) is deprecated at - line 3.
(Maybe you should just omit the defined()?)
########
# op.c
use warning 'deprecated' ;
defined(@a = (1,2,3));
EXPECT
-defined(@array) is deprecated (and not really meaningful) at - line 3.
+defined(@array) is deprecated at - line 3.
(Maybe you should just omit the defined()?)
########
# op.c
use warning 'deprecated' ;
defined(%h);
EXPECT
-defined(%hash) is deprecated (and not really meaningful) at - line 3.
+defined(%hash) is deprecated at - line 3.
(Maybe you should just omit the defined()?)
########
# op.c
use warning 'deprecated' ;
my %h; defined(%h);
EXPECT
-defined(%hash) is deprecated (and not really meaningful) at - line 3.
+defined(%hash) is deprecated at - line 3.
(Maybe you should just omit the defined()?)