Ahh, I did not really understand what the OP means with "-1"....
I would suggest an additional solution
Code:
$file[$line] =~ s/$sub_var_list=[-+]?\d+/$sub_var_list=$sub_var_list_val/ ;
which also is valid in cases where the number comes with a +sign.
And an additional explanation about the difference between @ and $. Perl is very contextsensitive. In your case the substitution is done for a line which is a scalar (a single string) and therefore it is $file[$line].
If you expect to make the substitution for
every line in @file you could instead write
Code:
s/$sub_var_list=[-+]?\d+/$sub_var_list=$sub_var_list_val/ for @file ;
which is a loop in a oneliner.
Markus