PDA

View Full Version : Reading data from a flat file.


mlseim
06-24-2003, 08:24 PM
I have a flat file database with "pipes" as my separaters.

With one script, it will read in my customer name with a space like "Bill Smith". $ccustname="Bill Smith"

With another script and a different file, it cuts off the customer name like "Bill" $ccustname="Bill"

I see nothing different with the two datafiles or the two scripts. Why is one getting cut-off between spaces?

This is driving me nuts!

The "pipe" is specified as the SPLIT in both cases. Why is it splitting at the space in one script, but not the other?

The code used in both scripts:
==========================================

open (ORGDB,"<$address_file");
@ODB=<ORGDB> ;
close (ORGDB);

foreach $rec(@ODB){
...more code
chomp($rec);
($ccustemail,$ccustid,$ccustname)=split(/\|/,$rec);
... more code
=======================================

Example Database used:

billsmith@aol.com|bs1234|Bill Smith|

Note the space between "Bill" and "Smith".
It looks the same in both data files.

mlseim
06-25-2003, 02:58 PM
OK, here's what is happening.

The problem is not in the SPLIT part, but in the FORM that I
am viewing.

When I read the data into the variable and then try to use it
as a value in my form, the string is cut-off at the space.

eg.

<.form>
Your Name: <.input type="text" name="custname" size=20 value=$ccustname><.br>

If $ccustname = "Bill Smith", it will only show up as "Bill" for the
value in the textbox.

So, nevermind about the first problem. Is there any way around
the "form value" problem?

ACJavascript
06-25-2003, 04:54 PM
well there could be a couple things that could be creating this problem..

1. Do you have any Filters in your script?
such like $value=~ s/ //g;
ect.?

2. Try putting \" quotes \" around the value of the textbox.


could you post the rest of the code? just the part were you have more code mabye the error is how it is being writtin out.

mlseim
06-25-2003, 08:42 PM
I put ' ' around the value (instead of " ")

That works!

And that's the difference between my two scripts ...
one form has ' ' around the values and the other does not.


<.form>
Your Name: <.input type="text" name="custname" size=20 value='$ccustname'><.br>


whew ...

That was a tough lesson for me.

Thanks for the help!