A Gentle Introduction
The use directive allows you to use a module in your Perl program. 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 probably be placed near the beginning of the program.
You may recall that we used the following module in Hour 10, “Files and Directories.” At that time, however, you didn't know how it worked. When you run a program with use Cwd, what actually happens is this:
The Perl interpreter opens your program and reads in all the code until the use Cwd statement is found.
When your Perl interpreter was installed, it was informed which directory ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access