in reply to Re: Re: Updating entry in DBM file adds extra character %09
in thread Updating entry in DBM file adds extra character %09

dbmopen

Consider using a tied hash instead.

print "Content-type: text/html", "\n\n";

You can add the \n\n in the first literal string.

die;

You shouldn't die unless a real error occurs. Bad user input is not considered a program error, so it should not output to STDERR (everything that is output to STDERR is appended to the error log of the webserver). Consider using exit instead.

if ($fields{'updsynpass'}==""){

Don't use == for string comparison. Use the string equality test operator eq instead.

$fields{'updalumemail'}::$fields{'updemailpub'}:: $fields{'updalumsnail1'}::$fields{'updsnail1pub'}::$fields{'updalums +nail2'}::$fields{'updsnail2pub'}:: $fields{'updalumsnail3'}::$fields{'updsnail3pub'}::$fields{'updphone +'}::$fields{'updphonepub'}::$fields{'updalumyears'}::$fields{'updyearspub'}:: $fields{'updcomment'}::$fields{'updcommentpub'}::$fields{'updsynpass +'}::$fields{'updsynpass2'}"

Ouch. Consider using join instead. That would also fix your original %09-character problem. join is the exact opposite of split.

$synusers{ $fields{updalumname} } = join '::', @fields{qw(updalumemail updemailpub updalumsnail1 updsnail1pub updalumsnail2 updsnail2pub updalumsnail3 updsnail3pub updphone updphonepub updalumyears updyearspub updcomment updcommentpub updsynpass updsynpass2)} +;

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk

Replies are listed 'Best First'.
Re: Re: Re: Re: Updating entry in DBM file adds extra character %09
by Anonymous Monk on Mar 19, 2002 at 03:49 UTC
    THANKS for the tips. Very helpful. Considered tie before but will give it more thought now. Also will try the join. Didn't realize hadn't replaced == with eq (teaching myself perl these past months when I have free time). Will try this stuff this week.
      Using join when creating each database record essentially fixed my problem. Thought I'd provide a summary of the answer for anyone looking up this prob in the future. Thanks, Perlmonks!!