Hi all
I have a file with below contents I need to store all the values in leftside into an array and right side into another array.
Filename:list.t xt
ram,kriz
rakesh,ssss
perl,unix
If we assume the array name as ltemp then ltemp[0] should have "ram"
ltemp[1] should have rakesh and ltemp[2] should have "perl".
I tried the same,
[CODE=perl]
open(FP,"list.t xt") or die "cannot open the list file";
while (<FP>) {
$temp = $_;
@ltemp = split(/,/ ,$temp);
print @ltemp[0];
}
close(FP);
[/CODE]
here ltemp[0] contains all the three elements and ltemp[1] has "kriz,rakesh,un ix"
How can I store each value in seperate array Index..
Hope you can get my question
I have a file with below contents I need to store all the values in leftside into an array and right side into another array.
Filename:list.t xt
ram,kriz
rakesh,ssss
perl,unix
If we assume the array name as ltemp then ltemp[0] should have "ram"
ltemp[1] should have rakesh and ltemp[2] should have "perl".
I tried the same,
[CODE=perl]
open(FP,"list.t xt") or die "cannot open the list file";
while (<FP>) {
$temp = $_;
@ltemp = split(/,/ ,$temp);
print @ltemp[0];
}
close(FP);
[/CODE]
here ltemp[0] contains all the three elements and ltemp[1] has "kriz,rakesh,un ix"
How can I store each value in seperate array Index..
Hope you can get my question
Comment