in reply to Re^9: Can't call method "otherwise" without a package or object reference at
in thread Can't call method "otherwise" without a package or object reference at

Well it seems I have stumbled onto a fix...
Previously the Error.pm was pulled in by one of my modules (myExceptions), which was pulled in by another module, that was pulled into the one running the code. Apparently that we too many levels or something, somehow (since it works in some cases not in others). But when I directly pulled in myExceptions in the module doing the code, it started working.
All said and done, this is better coding this way anyway...
So thanks for all the help... the otherwise clause does indeed work the way we thought... and all is well (well the script still doesn't work, but this isn't the reason why... :) )
  • Comment on Re^10: Can't call method "otherwise" without a package or object reference at

Replies are listed 'Best First'.
Re^11: Can't call method "otherwise" without a package or object reference at
by ikegami (Patriarch) on Oct 08, 2010 at 06:00 UTC

    Apparently that we too many levels or something

    No, there's no reason to believe the module wasn't being loaded. You simply never imported the functions into the current package.

      I follow what you are saying, but then I can't explain why the other try catch blocks in the same sub tested fine.

        It makes no sense for them to be defined one place in the sub and not another (unless you have something weird in the sub like a use directive). I suspect they didn't actually test fine.

        What was the output I requested? What's the Deparse -p of one that tested fine?

Re^11: Can't call method "otherwise" without a package or object reference at
by ikegami (Patriarch) on Oct 08, 2010 at 15:58 UTC
    Elaborating on the above post:
    { package PkgA; # Loads the module if it's not loaded, and import "foo". use SomeModule qw( foo ); foo(); # ok } { package PkgB; # Loads the module if it's not loaded, importing nothing. use SomeModule qw( ); foo(); # Error. No such function in PkgB SomeModule::foo(); # ok } { package PkgC; # The module might be loaded, but nothing is imported from it. foo(); # No such function in PkgC }

    You package is like PkgC.