I am just learning how to use Perl and while looking through the examples given on learn.perl.org/examples/, I came across this error on multiple example programs saying:
Can't locate Path/Class.pm in @INC (@INC contains: C:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .) at read_file.pl line 5. BEGIN failed--compilation aborted at read_file.pl line 5.
This is the code from each of the examples:
#!/usr/bin/perl
use strict;
use warnings;
use Path::Class;
use autodie; # die if problem reading or writing a file
my $dir = dir("/tmp"); # /tmp
my $file = $dir->file("file.txt");
# Read in the entire contents of a file
my $content = $file->slurp();
# openr() returns an IO::File object to read from
my $file_handle = $file->openr();
# Read in line at a time
while( my $line = $file_handle->getline() ) {
print $line;
}
and:
#!/usr/bin/perl
use strict;
use warnings;
use Path::Class;
my $dir = dir('foo','bar'); # foo/bar
# Iterate over the content of foo/bar
while (my $file = $dir->next) {
# See if it is a directory and skip
next if $file->is_dir();
# Print out the file name and path
print $file->stringify . "\n";
}