What is Difference between Function and subroutine in perl ? I found difference in few site, there i found Subroutine does not return value but function returns but actually Subroutine also return value . Please let me know What is Exact difference between Function and subroutine in perl ?
-
They are synonyms. Not different termsKrishnachandra Sharma– Krishnachandra Sharma2013-03-11 13:06:28 +00:00Commented Mar 11, 2013 at 13:06
-
@KrishnachandraSharma Actually in some programming languages they are different.Brad Gilbert– Brad Gilbert2013-03-11 18:07:51 +00:00Commented Mar 11, 2013 at 18:07
-
Ok. That I didn't know. But here I meant specifically in perl.Krishnachandra Sharma– Krishnachandra Sharma2013-03-11 18:20:21 +00:00Commented Mar 11, 2013 at 18:20
Add a comment
|
1 Answer
Generally in computer science a function is a special type of subroutine that returns a values (as opposed to being called just for its side-effects). But in Perl (as the cookbook says) we don't make that distinction.
The two words mean the same thing. They're synonyms.
Course: Perlmonks.
Update: They are synonyms only because Perl returns last value of expression, evaluated in sub-block.
2 Comments
gaussblurinc
They are synonyms only because
Perl returns last value of expression, evaluated in sub-blockRickF
Actually, they're synonyms only in that perl has no formal definition of a function - only
sub. It has nothing to do with the return value.