0

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 ?

3
  • They are synonyms. Not different terms Commented Mar 11, 2013 at 13:06
  • @KrishnachandraSharma Actually in some programming languages they are different. Commented Mar 11, 2013 at 18:07
  • Ok. That I didn't know. But here I meant specifically in perl. Commented Mar 11, 2013 at 18:20

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

They are synonyms only because Perl returns last value of expression, evaluated in sub-block
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.