http://www.perlmonks.org?node_id=918110


in reply to Re: including modules during runtime and dealing with OS specific (constants) code block
in thread including modules during runtime and dealing with OS specific (constants) code block

First, the functions, SetAttributes and GetAttributes, must be specifically requested:
use Win32::File qw(:DEFAULT SetAttributes GetAttributes);

That would not actually make any difference here. The only difference it would make is allowing this syntax:

GetAttributes()

Instead of this:

Win32::File::GetAttributes()

...which is not being attempted here. That specification just tells import() what to bring into the current package namespace from the module.

The issue in play here is the 'eval', which gives the compiler no idea what will be available at runtime. So it fails at compile time. In your 'fixed' example, it's working not because of your added imports, its working because you removed the 'eval'.

--Dave

  • Comment on Re^2: including modules during runtime and dealing with OS specific (constants) code block
  • Select or Download Code