[boulder.pm] Broken User Modules.

Dan Moore moore at xor.com
Fri Jun 9 16:45:19 CDT 2000


On Fri, 9 Jun 2000, Robert L. Harris wrote:

> 
> 
> A user wrote a module, "LOADgen3.pm" which is in $SCRIPT.  $SCRIPT may
> change, depending on the machine, not my choice.  I'm trying this:
> 
> #!/local/bin/perl -w
> 
> use diagnostics;
> use strict;
> 
> #
> # Let's get jwarnick's script
> #
> #require "$ENV{SCRIPT}"."/"."LOADgen3.pm";
> #use "$ENV{SCRIPT}"."/"."LOADgen3.pm";
> my ($ScriptDir)="$ENV{SCRIPT}";
> my ($LoadGen3Script)="$ScriptDir"."/"."LOADgen3";
> use $LoadGen3Script;
> 
> Neither the use, or the require work.  I get this:
> 
> 
> powermrt at caroline:/load/Demo $ ./DefMungeSplit.pl -f /load/DEF.EBCDIC-06-07-2000-10-00.gz
> syntax error at ./DefMungeSplit.pl line 11, near "use "$ScriptDir""
> Execution of ./DefMungeSplit.pl aborted due to compilation errors (#1)
>     
>     (F) The final summary message when a Perl compilation fails.
>     
> Uncaught exception from user code:
>         Execution of ./DefMungeSplit.pl aborted due to compilation errors.
>

I think you might need to use a BEGIN block, since 'use' happens at compile
time.  That is to say,

BEGIN {
    my ($ScriptDir)="$ENV{SCRIPT}";
    my ($LoadGen3Script)="$ScriptDir"."/"."LOADgen3";
    use $LoadGen3Script;
}

I'm not sure about having the 'use' in the BEGIN block, but then again, I'm
leery of putting it outside the BEGIN block because of the use of my
variables.

Hope this helps.

Dan




More information about the Boulder-pm mailing list