Hi, I'm working with a line of numbers from a file in the form:
( 0, 670); 3.2; 7.8; 9.4; 10.2; 12.6;
I know that I can use these lines:
$line = <FILE>;
@split1 = split(/;/, $line);
which will result in the array @split1 containing:
@split1[0] = ( 0, 670)
@split1[1] = 3.2
@split1[2] = 7.8
etc.
the 1st and 2nd elements are already fine, but I need to get the numbers out of the 0th element. If I then combine the following:
$line = <FILE>;
@split1 = split(/;/, $record);
@split2 = split(/,/, @split1[0]);
@split3 = split(/\(/, @split2[0]);
@split4 = split(/\)/, @split2[1]);
$test1 = @split3[1];
$test2 = @split4[0];
then $test1 and $test2 then contain the numbers I want. Two questions, is there a more elegant way to do this, I'm sure there must be. Second question, can I then use $test1 and $test2 just like numbers, i.e. perform operations on them like +, -, * and /?
Thanks in advance for any help.