SPUG: Stupid Ascii question

Colin Meyer cmeyer at helvella.org
Thu Aug 15 12:56:08 CDT 2002

On Thu, Aug 15, 2002 at 09:54:44AM -0700, Peter Darley wrote:
> Friends,
> 	I am working with database stuff and I want to store deleted database
> records, so there's a history of what was in the database.  I have chosen to
> do this by having my front end app, written in Perl, put all the field names
> and values into a single string separated by a non-printing Ascii character
> which I can just do a split() on later to return a hash of the record, which
> is exactly what I would get if I did a fetchrow_hashref() on the original
> record.

I would suggest two alternatives. Since you are already using a
database, which does a good job of keeping separate fields, you could
use another table to hold the deleted records. This table would simply
have the same columns as the original table. Trying to encode and decode
fields from a string seems like a lot of extra work that the db is quite
capable of.

Another option would be to use Text::CSV_XS. This is a module that is
very good at joining and splitting fields to and from strings. You can
select the separator character, or let it use the default comma (which
it automatically escapes within your fields).

Have fun,

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org

More information about the spug-list mailing list