November 25th, 2013, 03:15 PM
I'm just over here messing around with subroutines, trying to get used to them, but I have hit a stumbling block
Why doesn't this code work:
This is my error message: "Can't modify non-lvalue subroutine call in scalar assignment at ./hw6 line 13, near "$print;"
my $first_val = $_;
my $second_val = $_;
return($first_val + $second_val);
Experiment(5,6) = $number;
This code just adds the two arguments that get inputted. Why doesn't it work? I'm guessing it has something to do with the numerical aspect of it, because I can run a subroutine that does a print job with no problem.
November 25th, 2013, 05:45 PM
Look at how you assigned value to $first_val and $second_val.
Now look at how you try to assign a value to $number. It is at the wrong side at the =.
Try change that line to:
$number = Experiment(5,6);
Comments on this post