Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

import not getting called in a module

by danmcb (Monk)
on Feb 27, 2013 at 18:35 UTC ( #1020942=perlquestion: print w/replies, xml ) Need Help??
danmcb has asked for the wisdom of the Perl Monks concerning the following question:

I am using a module and passing a parameter to it in the use statement. The module is part of a Catalyst test harness. But the import routine never gets called.

When I do the same thing in a simple module (i.e. not part of Catalyst stuff) it works fine.

My code:

package test_setup; use strict; use warnings; our $data_file; sub import { my ($package, $df) = @_; # we never get here $data_file = $df if defined $df; } # etc 1;

And the test file:

use strict; use warnings; use t::test_setup qw/ file_name /; use Test::More tests => 6; #etc

Any idea what could cause this?

Replies are listed 'Best First'.
Re: import not getting called in a module
by bart (Canon) on Feb 27, 2013 at 18:37 UTC
    Because the package name is not the same as the name you use.


    package t::test_setup;

      oh man ...


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1020942]
Approved by bart
[LanX]: ah... Denmark is planning to build a wall at the German border!
[LanX]: # Pestis Africana Suum
[erix]: that's an old plan, I think. Isn't there already a danewal (or some such name)?
[marto]: Build with -Wall
[erix]: Danewerk
[LanX]: I seem to remember that the danewall was build by the Frankish empire against the Danes
[erix]: 500 AD thru viking age
[erix]: that would make sense but wikipedia thinks otherwise
[LanX]: oh me was wrong ...
[erix]: but it always works both ways of course

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2018-03-22 18:38 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (283 votes). Check out past polls.