它是什么? ['Y','N'] if(uc($ ENV {USERNAME})=〜/ $ super_users / i)

时间:2015-10-09 18:36:28

标签: perl

我正在追踪不属于我的程序。以下表达意味着什么:

get_input(
   \$args_100{env}, 
   "\n\tAre these reports running out of the TEST environment (Y\/N)?",
   0,
   'N',
   '',
   ['Y','N']
) if( uc( $ENV{USERNAME} ) =~ /$super_users/i ) ;   

我理解if语句,但之前是否?

2 个答案:

答案 0 :(得分:6)

如果符号是后缀。见Statement Modifiers in perlsyn。它相当于

if ( uc( $ENV{USERNAME} ) =~ /$super_users/i ) {
    get_input(\$args_100{env}, 
        "\n\tAre these reports running out of the TEST environment (Y\/N) ?",
        0, 'N','',['Y','N']);
}

答案 1 :(得分:1)

简短的回答是['Y','N']创建了一个包含两个单字符字符串"Y""N"的数组,并返回对该数组的引用。该引用将作为调用get_input

的第六个和最后一个参数传递
get_input(
   \$args_100{env}, 
   "\n\tAre these reports running out of the TEST environment (Y\/N)?",
   0,
   'N',
   '',
   ['Y','N']
) if( uc( $ENV{USERNAME} ) =~ /$super_users/i ) ;