Hello, Mark,
Wednesday, July 06, 2005, 4:11:12 PM, You wrote:
DM> Trying write code that work for both UNIX and MSWin32 Mail.
DM> This runs on Solaris but doesn't work on windows
DM> $win32ole = 'Win32::OLE qw(in with)';
DM> $winconst = "Win32::OLE::Const 'Microsoft Outlook'";
DM> if ($^O eq 'MSWin32'){
DM> require $win32ole;
DM> require $winconst;
DM> $Win32::OLE::Warn = 3; # die on errors...
DM> }
DM> I get the following error:
DM> Can't locate Win32::OLE qw(in with) in @INC (@INC contains:
DM> /package0/filpods/loaders . C:\Program Files\ActiveState Komodo
DM> 3.1\dbgp\perllib C:\Program Files\ActiveState Perl Dev Kit 6.0\lib\
DM> C:/Perl/lib C:/Perl/site/lib) at
DM> Y:\FILPODS\DB\loaders\factsheet_extract.pl line 30.
the error occurs because expression after keyword require isn't
bareword. In perlfunc we can see:
[quoting starts]
require EXPR;
...
If EXPR is a bareword, the require assumes a ``.pm'' extension and replaces
``::'' with ``/'' in the filename for you, to make it easy to load standard
modules.
This form of loading of modules does not risk altering your namespace.
In other words, if you try this:
require Foo::Bar; # a splendid bareword
The require function will actually look for the ``Foo/Bar.pm'' file in the
directories specified in the @INC array.
But if you try this:
$class = 'Foo::Bar';
require $class; # $class is not a bareword
#or
require "Foo::Bar"; # not a bareword because of the ""
The require function will look for the ``Foo::Bar'' file in the @INC array and
will complain about not finding ``Foo::Bar'' there. In this case you can do:
eval "require $class";
[quoting ends]
--
Best regards,
Sergey mailto:[EMAIL PROTECTED]
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs