- 论坛徽章:
- 0
|
本帖最后由 jjqing 于 2014-03-17 13:33 编辑
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
use Smart::Comments '###';
my (%hash,$result);
%hash = (
cluster_name => undef,
column_name => 'OBJ#',
column_position => '1',
extents => '102',
index_name => 'I_IDL_UB11',
index_size => 2097152,
index_tablespace_name => 'SYSTEM',
index_type => 'NORMAL',
iot_type => undef,
nested => 'NO',
owner => 'SYS',
table_name => 'IDL_UB1$',
table_size => 260046848,
tablespace_name => 'SYSTEM',
temporary => 'N'
);
### %hash
push ( @$result, { %hash } );
### $result
foreach my $a ( @{ $result } ) {
my $hash;
### $a
if ( defined $a->{cluster_name} ) { #此处为何老是报"Use of uninitialized value"
$hash->{table_type} = 'CLUSTER';
}
elsif ( defined $a->{iot_type} ) {
$hash->{table_type} = $a->{iot_type};
}
elsif ( $a->{nested} ne "NO" ) {
$hash->{table_type} = '嵌套表';
}
elsif ( $a->{temporary} ne "N") {
$hash->{table_type} = "临时表";
}
elsif ( $a->{partitioned} eq "YES") {
$hash->{table_type} = "分区表";
}
else {
$hash->{table_type} = "堆表";
}
}
=d 以下是运行屏幕显示
[teamsun@TeamWorks tmp]$ perl 8
### $a: {
### cluster_name => undef,
### column_name => 'OBJ#',
### column_position => '1',
### extents => '102',
### index_name => 'I_IDL_UB11',
### index_size => 2097152,
### index_tablespace_name => 'SYSTEM',
### index_type => 'NORMAL',
### iot_type => undef,
### nested => 'NO',
### owner => 'SYS',
### table_name => 'IDL_UB1$',
### table_size => 260046848,
### tablespace_name => 'SYSTEM',
### temporary => 'N'
### }
Use of uninitialized value in string eq at 1 line 35 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.
=cut
请问各位,为什么对这个HASH VALUE判断老是出错呢?谢谢!
|
|