Dependent variable
Also called an outcome variable and response variable, a dependent variable is a variable whose value relies on the outcome of another operation or other variables. For example, a student's GPA (grade point average) is a dependent variable because its value is determined by the averages of all course marks.
In contrast, an independent variable or predictor variable is a variable whose value does not rely on another operation or variable. An example is a person's age because no other input can change someone's age.
Programming a dependent and independent variable
Below is an example Perl script that accepts input from a user, which is considered the independent variable. The "$age" variable is independent in this example.
The output variable, called "$ten" in our example, is dependent because it relies on the input's value.
use strict;
print "\nWhat is your age? ";
my $age = <STDIN>;
if ($age =~ /^[0-9]+$/) { $ten = $age + 10; print "In ten years, you'll be: $ten, that's old.\n"; } else { print "Invalid age.\n"; }
Running the script above would ask you, "What is your age?" If you entered "44," the script would print, "In ten years, you'll be 54, that's old."