in reply to Re: Re: Tie::RefHash
in thread Tie::RefHash

I think that you'd be better off using something like DBD::CSV or Text::CSV.

tie is intended to be used to tie a Perl variable (scalar, array, or hash) with a subroutine so that, to the user, it seems that they're using a regular Perl variable but every time they access that variable they are, in reality, invoking a subroutine call that handles the data in a form that is maybe totally different from normal Perl variables.

The reason that tie might be used with database modules is that it provides a simple, intuitive interface to the data. For example, the user can get a scalar variable tied to a DB field that, every time they read the value of that variable, the DB module looks up the field data for the next record in the DB. Or they could receive a tied hash that looks up field values by name instead of the user having to remember what order the fields are in and without the DB having to read an entire record into memory at once.

So, while you could build a tied variable interface to the files, you'll still have to build the routines to read that data in from the files. And for that, you'd probably want to go with one of the two CSV modules I mentioned above or, perhaps, one of the DBI modules...

Forgive me if I've rambled a bit and am not making any sense. It happens some times!  =) Let me know if that helps (or doesn't)!

bbfu

Replies are listed 'Best First'.
Re: (bbfu)Re: Re: Re: Tie::RefHash
by malaga (Pilgrim) on Jan 30, 2001 at 23:28 UTC
    i looked up both of those modules, but the server i'm working on doesn't have them, and it's next to impossible to get anything added, so it's a moot point. but the Text::CSV looked like it might have helped. thanks!

      Well, I'm not totally sure about this so don't get mad if I'm wrong. ;)

      You say you have a hard time getting modules installed at the site your on, but do you have a write access to a local (user) directory? If so, you might be able to install the module (Text::CSV) into that local directory and then modify the @INC in your program via use lib.

      I know for sure that there are one or two modules that require some other things to be installed in specific places or to have some C programs compiled but I don't think Text::CSV is one of them. You'll have to look at the documentation or try installing it to be sure.

      I like to put the module in the same directory as the script, and then in the script's code add the lines:

      use lib '.'; use Text::CSV;

      Of course, you should note that for a module like Text::CSV, you'll have to create a subdirectory named Text and put the module file (named CSV.pm) in it (standard convention, of course) but the install should do that for you.

      Anyway, I hope this helps!

      bbfu
      Seasons don't fear The Reaper.
      Nor do the wind, the sun, and the rain.
      We can be like they are.