in reply to Dice.pm - I'm doing it wrong, somehow.

Are you sure that your "use Games::Dice" is using your Games::Dice, and not the original one (which I presume you installed from CPAN?)

Note that copying and adding functions to the copy isn't the best way of extending a module. I would either write a Games::Dice::Whitewolf which would either has a package Games::Dice::Whitewolf, which uses Games::Dice and (re)exports its functions, and has roll_whitewolf, or adds 'roll_whitewolf' to @Games::Dice::EXPORT_OK and has a Games::Dice::roll_whitewolf.

In either case, if the original Games::Dice gets updated, you don't have to change your code (assuming it doesn't change its API).

  • Comment on Re: Dice.pm - I'm doing it wrong, somehow.

Replies are listed 'Best First'.
Re^2: Dice.pm - I'm doing it wrong, somehow.
by pobocks (Chaplain) on Oct 17, 2008 at 01:51 UTC

    Sadly, yes, as I don't have Games::Dice installed. First thing I checked. I don't even see how it could be cached somewhere, as I've tested that altering my Dice.pm alters the program's behavior (Deleting subroutines from Dice.pm causes errors was my test).

    I'm not planning on doing it this way "For keeps." I emailed the function to the module's maintainer as a "rough draft." I'm just perplexed as to why this isn't working for me, since my function is designed identically and in the same context as the two native functions.