Some of the environmnet variables which we use in Unix are as below (just an example):
VAR1=variable1
VAR2=variable2
VAR3=variable3
# and so on
Now, I have a perl script (let's call it test.pl) which reads a tab delimited text file (let's call it test.txt) and pushes the contents of it columnwise in separate arays. The first column of test.txt contains the following information for example (the strings in first column are delimited by / but I do not know how may / would a string contain and at what postion the environment variable would appear):
$VAR1/$VAR2/$VAR3
$VAR3/some_string/SOME_OTHER_STRING/and_so_on/$VAR2
$VAR2/$VAR1/some_string/some_string_2/some_string_3/some_string_n/$VAR2
The extract of the script is as below:
use strict;
my $input0=shift or die "must provide test.txt as the argument 0\n";
open(IN0,"<",$input0) || die "Cannot open $input0 for reading: $!";
my @first_column;
while(<IN0>)
{
chomp;
my @cols=split(/\t/);
my $first_col=`eval $cols[0]`; #### but this does not work
# here goes the push stmt to populate the array
### more code here
}
close(IN0);
Question: How can I access evnironment variables in such a situation so that the array is populated as below:
$first_column[0]=variable1/vraible2/variable3
$first_column[1]=variable3/some_string/SOME_OTHER_STRING/and_so_on/variable2
$first_column[2]=variable2/variable1/some_string/some_string_2/some_string_3/some_string_n/variable2