Chapter 14. Using Perl modules, using CPAN

14.1. Using modules exporting functions

use Cwd;
my $path = cwd;

Probably better this way, so the reader will know where each function comes from and we reduce the risk of redefining other functions by importing exactly the functions we want.

use Cwd ('cwd');
my $path = cwd;

also written as

use Cwd qw(cwd);
my $path = cwd;

You can also make sure not to import anything and the use fully qualified names.

use Cwd ();
my $path = Cwd::cwd;

If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed