summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-08-01 18:34:41 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-08-01 18:34:41 +0000
commit475342a6d5f74335e2bdfa64bd71f39289320205 (patch)
treefab7566350d719b51095369676644c6ec89a3cf0
parent4584684cd9409a5028e679de2f80cf97a3a728bd (diff)
downloadperl-475342a6d5f74335e2bdfa64bd71f39289320205.tar.gz
fix defined(@foo) encarpments
p4raw-id: //depot/perl@3848
-rw-r--r--ext/B/B/C.pm2
-rw-r--r--lib/CGI.pm10
-rw-r--r--lib/Dumpvalue.pm14
-rw-r--r--lib/dumpvar.pl14
-rw-r--r--pod/perltrap.pod3
5 files changed, 23 insertions, 20 deletions
diff --git a/ext/B/B/C.pm b/ext/B/B/C.pm
index dd4db037a7..39a78c98e6 100644
--- a/ext/B/B/C.pm
+++ b/ext/B/B/C.pm
@@ -1207,7 +1207,7 @@ sub mark_package
{
no strict 'refs';
$unused_sub_packages{$package} = 1;
- if (defined(@{$package.'::ISA'}))
+ if (@{$package.'::ISA'})
{
foreach my $isa (@{$package.'::ISA'})
{
diff --git a/lib/CGI.pm b/lib/CGI.pm
index b1319260fd..c0cb5fd518 100644
--- a/lib/CGI.pm
+++ b/lib/CGI.pm
@@ -355,7 +355,7 @@ sub init {
# if we get called more than once, we want to initialize
# ourselves from the original query (which may be gone
# if it was read from STDIN originally.)
- if (defined(@QUERY_PARAM) && !defined($initializer)) {
+ if (@QUERY_PARAM && !defined($initializer)) {
foreach (@QUERY_PARAM) {
$self->param('-name'=>$_,'-value'=>$QUERY_PARAM{$_});
}
@@ -841,7 +841,7 @@ END_OF_FUNC
sub keywords {
my($self,@values) = self_or_default(@_);
# If values is provided, then we set it.
- $self->{'keywords'}=[@values] if defined(@values);
+ $self->{'keywords'}=[@values] if @values;
my(@result) = defined($self->{'keywords'}) ? @{$self->{'keywords'}} : ();
@result;
}
@@ -1906,14 +1906,14 @@ sub _tableize {
# rearrange into a pretty table
$result = "<TABLE>";
my($row,$column);
- unshift(@$colheaders,'') if defined(@$colheaders) && defined(@$rowheaders);
- $result .= "<TR>" if defined(@{$colheaders});
+ unshift(@$colheaders,'') if @$colheaders && @$rowheaders;
+ $result .= "<TR>" if @$colheaders;
foreach (@{$colheaders}) {
$result .= "<TH>$_</TH>";
}
for ($row=0;$row<$rows;$row++) {
$result .= "<TR>";
- $result .= "<TH>$rowheaders->[$row]</TH>" if defined(@$rowheaders);
+ $result .= "<TH>$rowheaders->[$row]</TH>" if @$rowheaders;
for ($column=0;$column<$columns;$column++) {
$result .= "<TD>" . $elements[$column*$rows + $row] . "</TD>"
if defined($elements[$column*$rows + $row]);
diff --git a/lib/Dumpvalue.pm b/lib/Dumpvalue.pm
index 9c596ffc05..22a10af014 100644
--- a/lib/Dumpvalue.pm
+++ b/lib/Dumpvalue.pm
@@ -91,7 +91,7 @@ sub stringify {
{ no strict 'refs';
$_ = &{'overload::StrVal'}($_)
if $self->{bareStringify} and ref $_
- and defined %overload:: and defined &{'overload::StrVal'};
+ and %overload:: and defined &{'overload::StrVal'};
}
if ($tick eq 'auto') {
@@ -162,7 +162,7 @@ sub unwrap {
my $val = $v;
{ no strict 'refs';
$val = &{'overload::StrVal'}($v)
- if defined %overload:: and defined &{'overload::StrVal'};
+ if %overload:: and defined &{'overload::StrVal'};
}
($address) = $val =~ /(0x[0-9a-f]+)\)$/ ;
if (!$self->{dumpReused} && defined $address) {
@@ -324,12 +324,12 @@ sub dumpglob {
print( (' ' x $off) . "\$", &unctrl($key), " = " );
$self->DumpElem($stab, 3+$off);
}
- if (($key !~ /^_</ or $self->{dumpDBFiles}) and defined @stab) {
+ if (($key !~ /^_</ or $self->{dumpDBFiles}) and @stab) {
print( (' ' x $off) . "\@$key = (\n" );
$self->unwrap(\@stab,3+$off) ;
print( (' ' x $off) . ")\n" );
}
- if ($key ne "main::" && $key ne "DB::" && defined %stab
+ if ($key ne "main::" && $key ne "DB::" && %stab
&& ($self->{dumpPackages} or $key !~ /::$/)
&& ($key !~ /^_</ or $self->{dumpDBFiles})
&& !($package eq "Dumpvalue" and $key eq "stab")) {
@@ -361,7 +361,7 @@ sub dumpsub {
sub findsubs {
my $self = shift;
- return undef unless defined %DB::sub;
+ return undef unless %DB::sub;
my ($addr, $name, $loc);
while (($name, $loc) = each %DB::sub) {
$addr = \&$name;
@@ -444,9 +444,9 @@ sub globUsage { # glob ref, name
local *stab = *{$_[0]};
my $total = 0;
$total += $self->scalarUsage($stab) if defined $stab;
- $total += $self->arrayUsage(\@stab, $_[1]) if defined @stab;
+ $total += $self->arrayUsage(\@stab, $_[1]) if @stab;
$total += $self->hashUsage(\%stab, $_[1])
- if defined %stab and $_[1] ne "main::" and $_[1] ne "DB::";
+ if %stab and $_[1] ne "main::" and $_[1] ne "DB::";
#and !($package eq "Dumpvalue" and $key eq "stab"));
$total;
}
diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl
index fb0bb2396f..f473c45bd3 100644
--- a/lib/dumpvar.pl
+++ b/lib/dumpvar.pl
@@ -53,7 +53,7 @@ sub stringify {
return $_ . "" if ref \$_ eq 'GLOB';
$_ = &{'overload::StrVal'}($_)
if $bareStringify and ref $_
- and defined %overload:: and defined &{'overload::StrVal'};
+ and %overload:: and defined &{'overload::StrVal'};
if ($tick eq 'auto') {
if (/[\000-\011\013-\037\177]/) {
@@ -125,7 +125,7 @@ sub unwrap {
if (ref $v) {
my $val = $v;
$val = &{'overload::StrVal'}($v)
- if defined %overload:: and defined &{'overload::StrVal'};
+ if %overload:: and defined &{'overload::StrVal'};
($address) = $val =~ /(0x[0-9a-f]+)\)$/ ;
if (!$dumpReused && defined $address) {
$address{$address}++ ;
@@ -289,12 +289,12 @@ sub dumpglob {
print( (' ' x $off) . "\$", &unctrl($key), " = " );
DumpElem $entry, 3+$off;
}
- if (($key !~ /^_</ or $dumpDBFiles) and defined @entry) {
+ if (($key !~ /^_</ or $dumpDBFiles) and @entry) {
print( (' ' x $off) . "\@$key = (\n" );
unwrap(\@entry,3+$off) ;
print( (' ' x $off) . ")\n" );
}
- if ($key ne "main::" && $key ne "DB::" && defined %entry
+ if ($key ne "main::" && $key ne "DB::" && %entry
&& ($dumpPackages or $key !~ /::$/)
&& ($key !~ /^_</ or $dumpDBFiles)
&& !($package eq "dumpvar" and $key eq "stab")) {
@@ -323,7 +323,7 @@ sub dumpsub {
}
sub findsubs {
- return undef unless defined %DB::sub;
+ return undef unless %DB::sub;
my ($addr, $name, $loc);
while (($name, $loc) = each %DB::sub) {
$addr = \&$name;
@@ -395,8 +395,8 @@ sub globUsage { # glob ref, name
local *name = *{$_[0]};
$total = 0;
$total += scalarUsage $name if defined $name;
- $total += arrayUsage \@name, $_[1] if defined @name;
- $total += hashUsage \%name, $_[1] if defined %name and $_[1] ne "main::"
+ $total += arrayUsage \@name, $_[1] if @name;
+ $total += hashUsage \%name, $_[1] if %name and $_[1] ne "main::"
and $_[1] ne "DB::"; #and !($package eq "dumpvar" and $key eq "stab"));
$total;
}
diff --git a/pod/perltrap.pod b/pod/perltrap.pod
index 321c86dd7f..50987cb102 100644
--- a/pod/perltrap.pod
+++ b/pod/perltrap.pod
@@ -761,6 +761,9 @@ Hashes get defined before use
# perl4 prints:
# perl5 dies: hash %h defined
+Perl will now generate a warning when it sees defined(@a) and
+defined(%h).
+
=item * (Globs)
glob assignment from variable to variable will fail if the assigned