Try this to load the code at run-time:

eval "require $some_module";
if($@){
        die $@;
}

José.


> -----Original Message-----
> From: Reinstein, Shlomo [mailto:shlomo.reinstein@;intel.com] 
> Sent: Thursday, October 17, 2002 8:57 AM
> To: 'Jenda Krynicky'; [EMAIL PROTECTED]
> Subject: RE: How to use a module located relative to the 
> current script
> 
> 
> Thanks. But how can I use the solution below in order to use 
> a module? Keep in mind that when I type:
>       use SomeModule;
> The "use" statement is executed at compile-time, not at 
> run-time. Therefore, if I want to find the location of the 
> current perl script, manipulate it and then use it to load 
> the module, I need to do all this in  BEGIN { } block so that 
> it takes place at compile-time. I tried it and for some 
> reason it didn't work, and since this happens at 
> compile-time, I don't even know how to debug it to see what 
> the problem is ("perl -d script" enters the debugger after 
> the compilation, so the BEGIN {} block has already been 
> executed, and in my case it simply told me there was an error 
> and it didn't enter the debugger).
> 
> Shlomo
> 
> -----Original Message-----
> From: Jenda Krynicky [mailto:Jenda@;Krynicky.cz]
> Sent: Wednesday, October 16, 2002 8:07 PM
> To: Reinstein, Shlomo; [EMAIL PROTECTED]
> Subject: RE: How to use a module located relative to the 
> current script
> 
> 
> From:                 "Reinstein, Shlomo" <[EMAIL PROTECTED]>
> > Thanks. However, I think this module won't help me. You see, 
> > "some_path/lib/sos.pl" is not the "original" (bin) script, 
> but rather 
> > it's a library of routines used by many "original" scripts. 
> That is to 
> > say, users don't run "perl some_path/lib/sos.pl", but 
> rather they run 
> > some other script which knows how to locate and require 
> sos.pl. Shlomo
> 
> I see. 
> Could you try to print
>       $INC{'sos.pl'}
> or (if that doesn't print anything) use
>       foreach (keys %INC) {
>               print "\t$_ => $INC{$_}\n";
>       }
> 
> This should tell you where was the sos.pl loaded from.
> You may then strip the 'sos.pl' from the path with a regexp and 
> append '../modules'.
> 
> Jenda
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to