Perl 101 (Part 5) - Sub-Zero Code (
Page 1 of 7 )
This week, Perl 101 introduces you to subroutines and teaches you
how to structure your code for maximum reusability. Also included: return
values, my() and local() constructs, and a marriage proposal.If you've been paying attention these last few weeks, you should know enough
about Perl to begin writing your own programs in the language. As a matter of
fact, you might even be entertaining thoughts of cutting down your weekly visits
to this Web site and doing away with this tutorial altogether.
Well, a
very wise man once said that a little knowledge was a dangerous thing...and so,
as your Perl scripts become more and more complex, you're going to bump your
head against the principles of software design, and begin looking for a more
efficient way of structuring your Perl programs.
Enter this week's
tutorial, which attempts to address that very problem by teaching you all you
need to know about a programming construct called a "subroutine". And - since
all work and no play is no way to live your life - we'll also be tossing in a
few pop culture references that should help make the lesson an interesting
[maybe even entertaining?] one.