in reply to New Problem?
in thread require $package?

It looks like you are running a messed up Perl 5.6 installation. Try the following code:
use Carp; croak("Test croak");
My bet is that you will get the same error. And the problem is that E:/Perl/lib/Carp/Heavy.pm probably has a syntax error in it. (Did someone edit it?) When you load Carp you don't see this error because the bulk of the module is autoloaded upon use. (This started with Perl 5.6, which is why I knew what version of Perl you had.)

But even if you fix that, you should work on your error handling. Using eval will trap errors, but if you are using eval, you should include $@ in your error message instead of guessing at what is wrong. Alternately you can use the file naming version of require. But as your code stands if your module doesn't return a true value, you will get an error that is confusing and counterproductive because it is wrong. (require is failing on a false return, but you will think it can't be found.)

Replies are listed 'Best First'.
Re: Re (tilly) 1: New Problem?
by Flame (Deacon) on Oct 17, 2001 at 06:47 UTC
    First: I've been able to use Croak in other sections of the module...

    Hmm, this is interesting though... I just looked through the code for the Spear package... I'm missing a semicolon on the first line ("package RPG::Item::Weapon::Spear")... heh...
    Well... after adding that, everything seems fine... Thanks for the help. :)


    "Wierd things happen, get used to it"

    Flame ~ Lead Programmer: GMS
    http://gms.uoe.org
      This is rather frustrating. I put a lot of energy into becoming a competent Perl programmer, I tell you a lot of valuable information point blank, and you just ignore it all?

      Sure, you have lots of croak calls. But if your code is like any half-way sane person's, none of them are expected to be called in regular use. Now based on what happened when you did call it, I am willing to bet that your installation is messed up.

      I am telling you that based on quite a bit of experience. Please do not disregard that statement. If it is true, then all of your error handling is going to be giving you back useless error messages. If you are a good programmer, that statement should bother you. A lot.

      Furthermore compare the error with what your code tries to put out. Your error reporting doesn't actually give the error it is supposed to. That is worrisome. However even if your code worked as you expect, the error message that you would have gotten would be wrong and misleading. That underscores my point that I made before about error handling, which you seem to be ignoring. But a good programmer wouldn't ignore that. A good programmer should be bothered if error handling gives you messages that send you down a blind alley. A good programmer doesn't want to make debugging harder.

      So I am telling you the following.

      1. I think you are dismissing my belief that your installation has problems far too easily.
      2. The fact that there is no connection between what the error was and what the message is that you got should be a giant red flag that should worry you.
      3. Your error handling is broken and needs fixing. Even if you got the message that you had worked to put there, the result would have just left you confused again. If you take the suggestions that I gave you earlier, this would not happen again.
      4. Your motto is, typos and all, "Wierd things happen, get used to it". Well that attitude is extremely dangerous in a programer. Yes, weird stuff happens. But you shouldn't just learn to live with it. Instead you should be bothered by it, investigate it, and make it so it doesn't happen any more.
      Well if I wasn't sick as a dog, I probably would rewrite this to come off in a kinder way. But I am, and I think that what I am saying has value. So please ignore the tone if you need to and focus on the message...
        Ahh, I'm afraid I mislead you

        I had actually taken into account what you had said, and changed the error message, however I did not feel that it warrented mentioning again. I suppose it did, but I was half asleep at the time.

        As to whether or not croak worked... I have been using it in many other programs over the past several months. And it was actually called with other errors in the program previously (I had already fixed those problems...)

        As to my motto. I don't just dismiss unusual things, I prefer to investigate them. (Hence the fact that I posted the confusing error message) However that doesn't mean you shouldn't get used to unusual things happening. Also, thanks for pointing out the misspelling. Heh, I never really paid attention to my own sig.

        The tone of the message was understandable, and I have no complaints.

        I thank you for your input.


        "Weird things happen, get used to it"

        Flame ~ Lead Programmer: GMS
        http://gms.uoe.org