Hello all,
I have the following subroutine:
I am having trouble undestanding what these lines are doing:
$newData = [];
push (@$newData,$line);
I think it is because you can only return a scalar var from a subroutine? But even if so, can someone explain to me how this works and what the guy is doing (I took over someone elses project and am trying to understand it.
Thanks,
Nick
I have the following subroutine:
Code:
sub RenumerateDSLines ()
{
my @DSLinesArray = @_;
# look for the same elements and add up their value fields
# after loop ends, output one line for each element type
# with the summ field updated
$index = 1;
$newData = [];
foreach $line (@DSLinesArray) {
@fields = split (",",$line);
$fields[0] = "\"$index\"";
$line = join (",",@fields);
push (@$newData,$line);
$index++;
}
return ($newData);
}
I am having trouble undestanding what these lines are doing:
$newData = [];
push (@$newData,$line);
I think it is because you can only return a scalar var from a subroutine? But even if so, can someone explain to me how this works and what the guy is doing (I took over someone elses project and am trying to understand it.
Thanks,
Nick