亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 3557 | 回復(fù): 3
打印 上一主題 下一主題

判斷HASH VALUE的未定義值出錯(cuò)(已解決) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2014-03-17 10:42 |只看該作者 |正序?yàn)g覽
本帖最后由 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ò)呢?謝謝!

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2014-03-17 13:23 |只看該作者
很感謝,原來(lái)就是因?yàn)?hash里面沒(méi)有'partitioned‘這個(gè)KEY,所以才導(dǎo)致這段報(bào)錯(cuò),現(xiàn)在已經(jīng)修改,使%hash包含了partition,運(yùn)行已經(jīng)不報(bào)錯(cuò)了。

謝謝!

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2014-03-17 13:12 |只看該作者
本帖最后由 jjqing 于 2014-03-17 13:24 編輯

回復(fù) 2# q1208c

不好意思,%hash里面沒(méi)有partitioned這個(gè)KEY,所以測(cè)試腳本改成如下,我的PERL版本是:This is perl, v5.8.9 built for x86_64-linux
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use diagnostics;
  5. use Smart::Comments '###';

  6. my (%hash,$result);

  7. %hash = (
  8.     cluster_name => undef,
  9.     column_name => 'OBJ#',
  10.     column_position => '1',
  11.     extents => '102',
  12.     index_name => 'I_IDL_UB11',
  13.     index_size => 2097152,
  14.     index_tablespace_name => 'SYSTEM',
  15.     index_type => 'NORMAL',
  16.     iot_type => undef,
  17.     nested => 'NO',
  18.     owner => 'SYS',
  19.     table_name => 'IDL_UB1,
  20.     table_size => 260046848,
  21.     tablespace_name => 'SYSTEM',
  22.     temporary => 'N'
  23. );

  24. ### %hash
  25. push ( @$result, { %hash } );
  26. ### $result


  27. foreach my $a ( @{ $result } ) {
  28.     my $hash;
  29.     ### $a
  30.     if ( defined $a->{cluster_name} ) {
  31.         $hash->{table_type} = 'CLUSTER';
  32.     }
  33.     elsif ( defined $a->{iot_type} ) {
  34.         $hash->{table_type} = $a->{iot_type};
  35.     }
  36.     elsif ( $a->{nested} ne "NO" ) {
  37.         $hash->{table_type} = '嵌套表';
  38.     }
  39.     elsif ( $a->{temporary} ne "N") {
  40.         $hash->{table_type} = "臨時(shí)表";
  41.     }
  42.     else {
  43.         $hash->{table_type} = "堆表";
  44.     }

  45. }
復(fù)制代碼

論壇徽章:
33
榮譽(yù)會(huì)員
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-04-17 06:23:27操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-04-24 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-05-06 12:46:59
2 [報(bào)告]
發(fā)表于 2014-03-17 11:49 |只看該作者
本帖最后由 q1208c 于 2014-03-17 11:50 編輯
  1.    elsif ( $a->{partitioned} eq "YES") {
  2.         $hash1->{table_type} = "分區(qū)表";
復(fù)制代碼
我這里是這段報(bào)錯(cuò).
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP