Exercise

See Appendix A for answers to the following exercise:

  1. [15] Install the Module::CoreList module from CPAN. Print a list of all of the modules that came with Perl 5.006. To build a hash whose keys are the names of the modules that came with a given version of Perl, use this line:

        my %modules = %{ $Module::CoreList::version{5.006} };
  2. [15] Get a list of filenames in the current directory. Use the C<Cwd> module to get the current directory, then use the C<File::Spec> module to join the directory name with the filenames to get an absolute path. Print the list of paths to standard outout with one path per line. Your solution should be portable to other operating systems.

  3. [15] Using the output from the previous exercise, read in a list of paths and use the C<File::Basename> module to extract the filename from each path. Print each name on a line by itself. Your solution should be portable to other operating systems.

Get Learning Perl, Fourth Edition 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.