0

我有一个 csv 文件,我从中逐行获取数据并调用函数并给出值。我只希望 csv 文件中的值之一可配置,因此我放置了 $ 符号,但其值未在程序,我已经将相同的值添加到程序中,以便它可以采用该值。

从 csv 文件中,我得到的值为:

1,    TC_6.01_UA_CREATE_USER    ,$create_user_command

这是功能: -

sub function{
    # $create_user_command --this is the global variable
    # that i take from the config file ;

    print "$create_user_command";
    # it is showing the command-- create user

    my $tc_name = $_[1];
    print "test case name : $tc_name\n";
    my $test_command = $_[2];
    # the value at the second index $_[2]is the value
    # from the csv file that i want to configure

    print "test case command: $test_command\n";
    # this is just simply printing the value from csv
    # i.e $create_user_command but not interpreting it
    print "$test_command\n";
}

我只想如何$create_user_command从 csv 中解释该值。请帮助我

4

1 回答 1

0

您希望使用 eval。

perldoc -f 评估

perldoc 评估

小心使用 eval ,它会运行任意代码,并且会严重地咬你。检查 $create_user_command 的值是否是您理解的,而不是类似于:

$create_user_command = "qx(rm -rf /)";  # BAD
于 2015-04-24T03:39:56.610 回答