0

I have a csv file from where I fetching the data line by line and calling the function and giving the value.. I just want one of the value in the csv file configurable so I put the $ sign but its value is not interpreted in the program and I already added the the same value into the program so that it can take that value.

from a csv file I getting the value as:

1,    TC_6.01_UA_CREATE_USER    ,$create_user_command

this is the function:-

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";
}

I just want how to interpret that $create_user_command value from the csv.. please help me in this

Jim Davis
  • 5,241
  • 1
  • 26
  • 22
yadav_1992
  • 43
  • 2
  • 11

1 Answers1

0

You way wish to use eval.

perldoc -f eval

perldoc eval

Use eval with care, it will run arbitrary code and can bite you very badly. Check that the value of $create_user_command is something you understand and not something like:

$create_user_command = "qx(rm -rf /)";  # BAD
xxfelixxx
  • 6,512
  • 3
  • 31
  • 38