Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 16. Writing Perl Modules

Chapter 16. Writing Perl Modules

It's time we learned how to share code across more than one of our scripts by creating our own Perl modules. This sort of code sharing is a really good idea. We've already seen how helpful it can be to take some block of code that is going to be used multiple times in a script and put it into its own subroutine. In the same vein, it's helpful to take common code that is going to be used in multiple scripts and put it into a module that can be shared by all of them.

The typical beginner's approach to sharing code is to just use copy-and-paste, which is, of course, a problem waiting to happen. Eventually you'll want to update that code to fix a bug or add some new capability. When that happens, you'll have to choose between updating one copy and leaving others in the old state (which is bad), or making the same changes over and over again (which is also bad, though in a different way).


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial