A subroutine can calculate a value and send it back with return.

Return Values

return_values.pl
use strict;
use warnings;

sub add_tax {
    my ($price) = @_;
    my $tax = 2;
    my $total = $price + $tax;
    return $total;
}

my $price = ;
my $total = add_tax($price);

print "price=$price\n";
print "total=$total\n";
use strict;
use warnings;

sub add_tax {
    my ($price) = @_;
    my $tax = 2;
    my $total = $price + $tax;
    return $total;
}

my $price = ;
my $total = add_tax($price);

print "price=$price\n";
print "total=$total\n";
use strict;
use warnings;

sub add_tax {
    my ($price) = @_;
    my $tax = 2;
    my $total = $price + $tax;
    return $total;
}

my $price = ;
my $total = add_tax($price);

print "price=$price\n";
print "total=$total\n";
return value A return value is the result a subroutine gives back to its caller.