in reply to OO: short memory?

To quote perl:

perhaps you forgot to load "Material::Variable::Pressure"?

With that as part of the debug message, it should be obvious that either your code does not load your Material::Variable::Pressure module or said module does not have this method defined. Stepping through in perldb might be a little late to catch the error as this is more of a BEGIN-time bug if the module isn't being loaded.

Of course this is all speculation until you SHOW US YOUR CODE!

Replies are listed 'Best First'.
Re^2: OO: short memory?
by Anonymous Monk on Jan 27, 2008 at 23:45 UTC
    As I said, at the beginning of the program are the 4 use statements.
    #!/usr/bin/perl -w use strict; use lib '/home/ghaverla/src/perl/lib/perl5'; use DBD::SQLite; use Materia::Variable::Generic; use Materia::Variable::Pressure; use Materia::Variable::Temperature; use Materia::Variable::PressureTemperature; use Data::Dumper;

    I really don't want to input the 9751 lines of code in this program. :-)

      Just curious, but how did you get 9,751 lines into your code before discovering that you couldn't create an object?

      Does Materia::Variable::Pressure have a new method? If not does Materia::Variable have a new method? If there is a new method can you reduce the problem to a simple case, for example cutting out all the methods except new?

        =pod Build up our list of hashes from 14th Chart of the Nuclides data. =cut my $hydrogen = {}; { $hydrogen->{element}{Z} = 1; $hydrogen->{name}{default} = 'Hydrogen'; $hydrogen->{name}{'en-CA'} = 'Hydrogen'; # Names for other countries/languages/charactersets. $hydrogen->{symbol}{default} = 'H'; $hydrogen->{symbol}{'en-CA'} = 'H'; # Symbols for other countries/languages/charactersets. $hydrogen->{element}{mass} = Materia::Variable::Generic->new({ value => '1.00794(7)', name => 'MolarMass', units => 'g', }); $hydrogen->{boilT} = Materia::Variable::Pressure->new({ value => '20.268', name => 'BoilT', units => 'K', pressure => { value => '101.325E3', units => 'Pa', }, });

        There are 106 elements of data, each one has a stanza about twice as long as this snippet for Hydrogen. The object is to merge a bunch of different data sources (some on paper, some electronically readable) into a database. But that is how this got to be almost 10,000 lines long.

        But the first creation of a Generic object, to store the Molar Mass of Hydrogen works. The next object to be created, the Boiling Point of Hydrogen (at a pressure of 1 atmosphere) fails.

        As written in the original note, the ::Generic, ::Pressure, ::Temperature and ::PressureTemperature modules have new methods. These methods do very little, mostly they shuffle a little information and call _init() in the base class.

        Anytime I find a problem, I redo the make/make install of these modules, so that what this program is loading when I run perldb in emacs is up to date. I don't just rerun the program from the beginning, I kill the perldb session in emacs and start it over again. But I have never run into this before where it looks like I have loaded the module, but at run time it can't find it. It's strange.

      Well of course, you don't need to show all your code, just the relevant stuff. Such as:
      • The loading statements (as you have provided, thanks)
      • The call site that fails (with any relevant surrounding context)
      • The package and loading statements of the module in question
      • The method in question
      If there's something thats a bit long, you can always use the <readmore> tag.

      If you don't give us a feel of what you're working with, its akin to asking us to wave a magic wand to fix it. Despite mentions of magic and wizardry, there are in fact very few Perl wizards.