Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Undefined subroutine errors

by leriksen (Curate)
on Oct 26, 2005 at 00:57 UTC ( #502915=note: print w/ replies, xml ) Need Help??


in reply to Undefined subroutine errors

Another solution - maybe not a good one - is this

#!/usr/bin/perl -w use strict; use warnings; use Spiderman qw(shootWeb); print STDERR shootWeb() . "\n"; package Spiderman; use base qw(Exporter); our @EXPORT = qw(shootWeb webStrength); use DrOctopus (); sub shootWeb { return DrOctopus::deflectWeb(); # from DrOctopus } sub webStrength { return 1; } package DrOctopus; use base qw(Exporter); our @EXPORT = qw(deflectWeb); use Spiderman (); sub deflectWeb { return Spiderman::webStrength(); # from Spiderman } 1;

...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann


Comment on Re: Undefined subroutine errors
Download Code
Re^2: Undefined subroutine errors
by ikegami (Pope) on Oct 26, 2005 at 03:05 UTC

    None of the functions provided by Exporter are called in your snippet. Why bother using Exporter?

    Update: In answer to my question, I suppose it gives the Green Goblin and other third parties the ability to import from these modules, but it detracts from the point of using fully qualified function names.

      In this case no, but that doesnt stop someone else using Spiderman or DrOctopus with the full export.

      As I said, it fixes his problem, YAWTDI, but not a great way.

      ...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann

        All you need to do is put BEGIN { ... } around our @EXPORT = ... (and remove the () from the use statements) and it works without fully qualified function names.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (19)
As of 2014-07-29 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (224 votes), past polls