programming-examples/perl/Subroutine/Passing parameters to subroutines.pl
2019-11-15 12:59:38 +01:00

19 lines
374 B
Perl

# Perl places all the parameters into an array named @_.
# You can access this array directly with the @_ syntax, or access individual parameters.
#!/usr/bin/perl -w
$value = add(5, 6);
print "Value from add=$value.\n";
$value = add(25, 1);
print "Value from add=$value.\n";
sub add {
my($a, $b) = @_;
my($sum) = $a + $b;
return $sum;
}