Question:
What is a subroutine?
Answer:
A subroutine is like a function ... called upon to excecute a task. Source: CoolInterview.com
When we are defining a function we have to use sub keyword in front of function name.<br><br>syntax:<br> sub functionname<br> {<br> statement;<br> }<br>Example:<br> if($a>0)<br> {<br> &fun();<br> }<br> sub fun<br> {<br> print "hai";<br> } Source: CoolInterview.com
Answered by: Gansi | Date: 9/6/2008
| Contact Gansi
Subroutine is perl is a block of code specially combined/grouped to perform a particular task.Which can e called at any point of time in a perl program.<br><br>Advantage using Subroutine<br> a) helps in modular programming making it easier to understand and maintain<br> b)eliminates duplication by reusing the same code/calling the subroutine. Source: CoolInterview.com
Answered by: Shubhadip Deb | Date: 11/11/2009
| Contact Shubhadip Deb
subroutine is a reusable piece of code. Source: CoolInterview.com
Answered by: shanthi | Date: 6/18/2010
| Contact shanthi
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|