in reply to Lady_TM

You mention that the code needs work. Here are some things I see that can be improved.
 

The prototypes on all of your subroutines conflict with the code in the subroutines. For example: sub new ($){ says that new takes a single argument, but then two arguments are shifted from @_:

my $self = shift; $self = bless {}; $self{'index_path'} = shift;
It is fortunate in this case that current versions of Perl ignore prototypes on method calls. :)
 

Your hardcoded LOCK constants are not platform compatible:

$LOCK_SH = '1'; $LOCK_EX = '2'; $LOCK_NB = '3'; $LOCK_UN = '4';
The constants from Fcntl should be used instead.
 

Globs, which are entries in the symbol table, do not include lexical variables, which are held outside the symbol table. In this code:

my %deleted_pair = (); $deleted_pair{$key} = $TABLE{$key}; delete ($TABLE{$key}); $self->update_index_table(\%TABLE); return (*deleted_pair)
the glob that is returned does not include the lexical hash that was just made. You probably want to return the hash itself, or a reference to it.
 

These are a few of the more egregious issues with the current state of your module. I hope you will continue making improvements.

Replies are listed 'Best First'.
Re: Re: Lady_TM
by Steeeeeve (Initiate) on Feb 02, 2001 at 02:58 UTC

    Thank you.

    Yes. There are many things to work on.

    Since comparing efficiency with that of a MS_Access session, I realize that Lady /TM approach to data access has merit. MS_Access uses something like a 1MB driver with an ODBC connection.

    I think a module to make it easy to create templates to be used with Lady /TM may be worth taking a look at as well. The templates would serve the same purpose as with EZDB allowing data management via a WWW connection.

    -Steeeeeve
Re: Re: Lady_TM
by Steeeeeve (Initiate) on Feb 04, 2001 at 09:59 UTC
    2-3-01 Fixed all globs to references wherever they occurred. Changed first shift in each method to use "$class" named variable. Added "get_nth_value... method.
Re: Re: Lady_TM
by Steeeeeve (Initiate) on Feb 02, 2001 at 03:48 UTC

    I am in the habit od using the line:

    my $self = shift;

    in each method that is to be accessed externally. Keeping a method private is sometimes desireable, those methods do not include the line. I took this from the good book "Perl from the Ground UP."

    In experience, if I forget to insert this line, the method IS unavailable. I do it now out of habit.

    Looking in the Perl Cookbook I see that this first shift is used to associate the method as a member of the "class object."

    This is not something that has anything to do with the method's prototype. The prototype will never take into account that the class association is the first shifted item in object-oriented Perl class method.

    Its something I don't understand fully, but I do it.

    -Steeeeeve

      I have never heard of "Perl from the Ground UP" so I cannot tell you whether or not it is bad. But be warned that there are lots of bad books out there, and I have probably heard of most of the worthwhile ones...

      Anyways using features when you don't understand what they are supposed to be doing is generally a bad idea. That leads to cargo-cult programming, a subject which leads to rants around here from time to time.

      In particular the only way you are getting away with your prototypes is that Perl is completely and absolutely ignoring them. Which means that if you ever try to write regular procedural code you will be hopelessly confused. For a full explanation try this rant.

      Beyond that, try putting:

      use strict;
      at the top of your module and seeing how much it complains. While you are at it do not write to globals in packages outside of yours without permission. (Yes, I am talking about $::Lady_TM.) It looks like you have not yet learned about pod. The (commented out) locking code makes a number of mistakes. Starting with trying to lock the filehandle before trying to open the file. That simply cannot work (though you don't test for the error so you wouldn't notice).

      Also for hashing you might want to look at existing modules. In particular the widely-used DB_File.

        I have Perl 5.6 ruining my server. (heh!) When I make an error with an unmatched prtotype, Perl complains about it.
        There is some error checking to add to the methods that actually get the file data. I will look into it.
        I remembered why I started using type globs, it didn't make any difference at the time what name was used on the other end.
        I am getting into some more work that involves the Lady TM module for my site wrapper,, so I'll be testing the revisions.
        Thanks for the input.
      A reply falls below the community's threshold of quality. You may see it by logging in.