Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Issue with Exporter

by ferreira (Chaplain)
on Jan 11, 2007 at 13:23 UTC ( #594146=note: print w/replies, xml ) Need Help??

in reply to Issue with Exporter

Don't forget to say

use strict; use warnings;
at the beginning of your modules and scripts, unless you have a very good reason not to do it.

Probably, method1 from is not getting called, but instead a stub that does nothing -- this is a "goodness" of not using strict (a promiscuous way to being too forgiven with unresolved symbols).

You will realize that if use strict; use warnings; were added, this will work as you expect, printing "its heremethod1 greets hellohere". But it is not right yet. The remaining issue is that to tell a package is inheriting the exporter capabilities from Exporter, you need

require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(method1);

The require statement will load for you. (And our will be need if you're "strict".) Why does it work only inserting use strict; use warnings; in Because some of these load Exporter and it becomes accessible as a side effect to the remaining of the script. This is not a thing to rely on. So I suggest you do the right thing: being strict, calling for warnings, requiring what you need. This will work always, not sometimes.

Replies are listed 'Best First'.
Re^2: Issue with Exporter
by palette (Scribe) on Jan 11, 2007 at 13:35 UTC
    It works. Thankyou. I shud adhere to the rules of being strict and use warnings.

    I would like to know why it is not working with use and working with require. Anyway use is require and import together right.


      It works for me with use Exporter; instead of require Exporter;. The point is that use'ing is not necessary when what you want is to inherit from Exporter in package one.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://594146]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2023-09-25 07:39 GMT
Find Nodes?
    Voting Booth?

    No recent polls found