- 論壇徽章:
- 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} ) { #此處為何老是報(bào)"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} = "臨時(shí)表";
}
elsif ( $a->{partitioned} eq "YES") {
$hash->{table_type} = "分區(qū)表";
}
else {
$hash->{table_type} = "堆表";
}
}
=d 以下是運(yùn)行屏幕顯示
[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
請(qǐng)問(wèn)各位,為什么對(duì)這個(gè)HASH VALUE判斷老是出錯(cuò)呢?謝謝!
|
|