The problem is that Perl uses
@l = (-1,-2,-3,-4,-5,-6);
for arrays (note the leading @, not $) and
for array elements (note the $l in this case, and square brackets).
is used to dereference array references. Thus if we define
$lRef = [-1,-2,-3,-4,-4,-6];
which is a reference to an array, we can get elements from it with
All that said, we can also use random to generate negative values:
$k = random(-6,-1,1);
which will have the same result as the intent of the sample code above.
how to pick a random element from a list
This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 10 posting(s) in 1 day