Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

leading spaces in a db

Status
Not open for further replies.

Moooink

Technical User
Feb 22, 2002
48
US
i have a script that makes a database of dates for a calendar. extra leading spaces are being added to the database thus not allowing the calendar to read the actual dates. the db file looks like this:

20010101~|~blahh~|~blahh~|~...
_20012010~|~nahr~|~kjnerh~|~...
_20010243~|~knah~|~knrh~|~...
_20022032~|~kjnrh~|~knreh~|~...

this is the submitsub that i think is causing the problem, if anyone could help that'd be great.


sub editsubmit {
if ($FORM{'form'} eq "dates") {
@varkeys = keys (%FORM);
foreach $line(@varkeys) {
unless ($line eq "action" || $line eq "form" || $line eq "$tempnum|del") {
($tempnum, $varname) = split(/\|/, $line);
if ($varname eq "date") {
$del = "$tempnum"."|"."del";
$date = "$tempnum"."|"."date";
$event = "$tempnum"."|"."event";
$url = "$tempnum"."|"."url";
unless ($FORM{"$del"} eq "yes") {
$list[$tempnum] = "$FORM{$date}~|~~|~~|~$FORM{$event}~|~$FORM{$url}~|~\n";
}
}
}
}
open (DATES,">$filedir/dates.txt") || &error("Can't Open dates.txt $!\n");
print DATES "@list";
close(DATES);
}
 
It looks like this line is causing the problem:

print DATES "@list";

When you print an array, each element is separated by a space. What you'd want to do is the following to avoid that situation.

open (DATES,">$filedir/dates.txt") || &error("Can't Open dates.txt: $!\n");
for ($a=0; $a<scalar(@list); $a++)
{
print DATES &quot;$list[$a]&quot;;
}
close(DATES);

(Please note: I didn't test this, but I'm pretty sure it won't place each element in a different line)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top