Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL return Function
Syntax
Definition and Usage
Returns EXPR at the end of a subroutine, block, or do function. EXPR may be a scalar, array, or hash value; context will be selected at execution time. If no EXPR is given, returns an empty list in list context, undef in scalar context, or nothing in a void context.
Return Value
Example
Try out following example:
#!/usr/bin/perl -w
$retval = Sum(5,10);
print ("Return value is $retval\n" );
@retval = Sum(5,10);
print ("Return value is @retval\n" );
sub Sum($$){
my($a, $b ) = @_;
my $c = $a + $b;
return($a, $b, $c);
}
|
It will produce following results:
Return value is 15
Return value is 5 10 15
| |
|

|
|
|