On Fri, 8 Jul 2005 12:05:08 -0700, you wrote: >Why does the use find the file and the require does not? > >The Win32.pm is located in, C:\Perl\lib\Win32.pm > >Can't locate Win32::OLE qw(in with) in @INC (@INC contains: >/package0/filpods/loaders . C:\Program Files\ActiveState Komodo >3.1\dbgp\perllib C:\perl\lib C:\perl\site\lib C:\Program >Files\ActiveState Perl Dev Kit 6.0\lib\ C:/Perl/lib C:/Perl/site/lib) at >Y:\FILPODS\DB\loaders\factsheet_extract.pl line 30. > >Code example cause error: > >$win32ole = 'Win32::OLE qw(in with)'; >$winconst = "Win32::OLE::Const 'Microsoft Outlook'"; > >if ($^O eq 'MSWin32'){ > require $win32ole; > require $winconst; > $Win32::OLE::Warn = 3; # die on errors... >}
There are two problems: 1) When you pass a string to use or require, Perl expects a file path, not the :: format. 2) The arguments after the module name are not processed by require when you pass a string. The simplest fix is eval "require $win32ole"; If this code will be executed many times in a single run of the program, a better way would be $win32ole = 'Win32/OLE.pm'; # extension is required too! require $win32ole; Win32::OLE->import('in', 'with'); All this obviously applies to the Win32::OLE::Const as well. -- Eric Amick Columbia, MD _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs