in reply to use Module (LIST) and 'import'

You don't understand the order in which things are executed I think. The use OtherModule part happens before $config is modified by import. Remember that use Blah qw(foo) is shorthand for BEGIN { require Blah; import Blah qw(foo); }. The use Othermodule happens when you require Blah which is before import has had a chance to run.

Replies are listed 'Best First'.
Re^2: use Module (LIST) and 'import'
by eXile (Priest) on Nov 30, 2004 at 22:04 UTC
    OK that's clear, thanks! Is there some other way to achieve my goal of being able to specify a config-parameter in a 'use'-statement and be able to pass it to other modules?
      This can be done like so:
      package Blah; use AppConfig; my $config = AppConfig->new(); sub import { my (%args) = @_; if ( $args{'Config'} ) { $config->file($args{'Config'}); } require OtherModule; OtherModule->import(Config => $config); #### next few lines for testing only use Data::Dumper; print Dumper(\%args); }
      --Stevie-O
      $"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc