.
is usually in @INC
, making Perl look in the current work directory for modules. It stopped working when you changed the CWD because nothing else in @INC
allowed it to find the module.
To look for modules in the relative to the directory in which the script is located:
use FindBin qw( $RealBin );
use lib $RealBin;
By the way, use lib 'Spreadsheet/ParseExcel.pm';
makes no sense whatsoever. The argument should be the directory in which Spreadsheet/ParseExcel.pm
is located (more or less).