Gentle Introduction

To use a module in your Perl program, you use the use directive to Perl. For example, to include the Cwd module in your program, simply place the following somewhere in your code:

use Cwd;

It doesn't matter where in your code you place the use Cwd, although for clarity and maintainability, it should go near the top of the program.

This particular module was used in Hour 10, "Files and Directories." But at the time, you didn't know how it worked. When you run a program with use Cwd, what actually happens is this:

  1. The Perl interpreter opens your program and reads in all the code until the use Cwd statement is found.

  2. When your Perl interpreter was installed, it was informed of its installation directory. That directory is searched ...

Get Sams Teach Yourself Perl in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.