Check whether refs are blessed before calling can()
This commit is contained in:
parent
29015e28a4
commit
a07d1f5120
@ -25,6 +25,7 @@ package Webperl::System;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use base qw(Webperl::SystemModule);
|
use base qw(Webperl::SystemModule);
|
||||||
|
use Scalar::Utils qw(blessed);
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Constructor and initialiser
|
# Constructor and initialiser
|
||||||
@ -89,7 +90,7 @@ sub clear {
|
|||||||
foreach my $key (keys %{$self}) {
|
foreach my $key (keys %{$self}) {
|
||||||
next if(!defined($self -> {$key})); # skip undefined refs
|
next if(!defined($self -> {$key})); # skip undefined refs
|
||||||
|
|
||||||
$self -> {$key} -> clear() if($self -> {$key} -> can("clear"));
|
$self -> {$key} -> clear() if(blessed($self -> {$key}) && $self -> {$key} -> can("clear"));
|
||||||
delete $self -> {$key};
|
delete $self -> {$key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user