SPUG: Stupid Ascii question
Trevor Leffler
tleffler at u.washington.edu
Thu Aug 15 12:54:52 CDT 2002
Peter,
I can't say that any non-printing ascii character would or wouldn't work for
you. However, I offer these two solutions:
1. You could use a printing character, and encode any instances of that
character in the data. For example, you might get away with using "," as a
delimiter and encode all other instances as "%2C". Obviously this makes the
assumption that the data will not already contain the string "%2C".
2. You could construct a hash of your field names and the corresponding values,
and then serialize the structure with, for example, Storable.pm. You can then
store this serialized structure to your database. Apache::Session is a module
that does this.
As an aside, since it appears that you're logging this data to your DB, which is
choking, have you considered logging to text files? They make for great logs:
easily accessible, readable, gzip-able, archive-able, backup-able.
--Trevor
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.
> My question is this; what non-printing Ascii character can I use for this?
> I wanted to use chr(0), the ascii null, but postgresql or DBD::Pg or DBI or
> something chokes on it. I went with chr(31) which is described as 'unit
> separator'. I'm worried that there may be some unexpected interaction with
> file systems or something that I'm unaware of, so I thought I'd ask y'all.
> Thanks,
> Peter Darley
>
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> 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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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