Gossamer Forum
Home : Products : DBMan : Installation :

Multi-word file names without a "_"

Quote Reply
Multi-word file names without a "_"
Howdy,

I'm using multiple db files and would like to re-name some of them so they would appear (print) in the html screens with a SPACE between each word.

Example: New York instead of New_York generated by my New_york.db file name in the config doc for each database.

How could I rename these .db files for this to happen? Much thanks.

Catster in TN
Quote Reply
Re: Multi-word file names without a "_" In reply to
Thank you for this workaround, dear reader. I was hoping there was just some additional characters that could be added to the file-name itself to produce a "space" in the html print-out. Anyone know?

Problem is, I need the corrected file name to appear in most every screen, otherwise visitors quickly lose track of where they are and then proceed to post data in the wrong places. Sigh...

Things would get pretty bloated to add all this new stuff to each section of the html file. (Right?) Any more ideas?

Catster
Quote Reply
Re: Multi-word file names without a "_" In reply to
You can create a separate hash which maps the filenames to 'html output' names something like the following. Hopefully the syntax is right as I am at the 'beginner' level with Perl. Smile

----------------------------------------

#!/usr/bin/perl

require "cgi-lib.pl";
&ReadParse(*input);

$db_one = "/path/to/New_York.db";
$db_two = "/path/to/New_Hampshire.db";
$db_three = "/path/to/South_Dakota.db";

%db_name_map = (
'$db_one' => 'New York',
'$db_two' => 'New Hampshire',
'$db_three' => 'South Dakota');

print "Content-type: text/html\n\n";
print qq~
<HTML>
<HEAD>
<TITLE>Search Results</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<H3>Search Results</H3>~;

if($input{'state'} eq $db_one)
{
print qq~
You selected $db_name_map{'$db_one'}.~;
}

print qq~
</BODY>
</HTML>~;
Quote Reply
Re: Multi-word file names without a "_" In reply to
I guess I don't understand your problem well enough. It would seem to me that once you have the mapped names in place using the hash, the amount of re-coding would be minimal. If you could clarify your question a little, maybe I would understand better and might be able to help.

Another option would be to use a relational database like MySQL if you have it available. DBMan is excellent but when you start getting into the realm of relational data there are some limitations with any Perl (flat file) database.

If you don't want to map the DB filename to a hash value, then I am not sure how to "change" the filename so it looks like "New York" instead of "New_York.db".



------------------
Scot Robnett
srobnett@earthlink.net
Quote Reply
Re: Multi-word file names without a "_" In reply to
Hi Scot,

I am running a directory of sorts with db file names for every state as well as several countries. It is driven by a seperate cgi and html file for each of 4 global regions.

A dedicated html file for each state or country could fix this thing but that creates too many docs.

Where exactly does this hash segment go (which you authored above)? It would be necessary for each different screen, right?

My problem in the past was that folks would browse the directory and forget what state they were in, then submit their data to the wrong state. This is why is need to be able to call this file name and display it.

I appreciate you very much.

David Anderson,
aka: Catster

Quote Reply
Re: Multi-word file names without a "_" In reply to
If I understand you correctly, you have a different .db file for each state. If so, you could add the following to your .cfg file:

Code:
$state = $db_setup;
$state =~ s/_/ /g;

(You can pretty much put it anywhere that seems logical.)

Then use the $state variable wherever you want to print out the current state.


------------------
JPD





Quote Reply
Re: Multi-word file names without a "_" In reply to
Wow. What an honor to have you weigh in on this detail, JPD. I'll be studying your answer... your typical sly answer.

You're Carol, right? What does JPDeni stand for, if I might inquire?

Anyway, you had assisted us before on this particular project. I recall at that time finding a candid post in which you were desperately trying to help somebody else (as always) and, in frustration, asked yourself the question: Am I really cut out for this kind of work?

We'll, we all know the answer to that one! You daily empower us, the ignorant and helpless. "Thank you" is an enormous understatement.

david anderson
bristol, tn
Quote Reply
Re: Multi-word file names without a "_" In reply to
Oh, my! I'm gettin' all misty!!! (No joke.)

"JPDeni" stands for "Just Plain Deni" -- "Deni" coming from my middle name, which is Denise. I picked the nickname up in high school -- a very long and boring story. Smile

Yes, Carol is my first name. That's what my family calls me. But those who are my closest friends call me "Deni."

I really do like helping folks. Sometimes it gets overwhelming and I end up spending much too much time here when I should be doing other things. (Minor little things like doing the dishes and making dinner. Smile ) I also like the way the programming keeps my ol' brain going. I'm pretty much confined to home for a number of reasons and it would be very easy for me to veg out in front of the tv while my brain cells completely atrophy. But this keeps me sharp.

As I mentioned somewhere recently, I've started my own new DBMan project and a lot of the things I've given to folks here has been useful for me. I didn't have to start completely from scratch. (One more humungous "thank you" to LoisC for creating an index of mods that I could use to find stuff.)

To tell you the truth (warning: another really candid moment coming up!), the thing that bothers me most about the forum are the times when people are unkind to each other. Much of this can be done without any "touchy-feely" stuff and that's fine. But I have read some things where a few folks are just plain mean in what they say. I am the sort of person that takes it all to heart. If someone says something unkind to another, and I read it, it's like he or she is saying it to me. That is a major reason that I left the forum last year. It started when I got a really awful headache, and had to be out for a while because of that. When the headache went away, I just couldn't bear coming back to a place that had become unpleasant.

When I came back, it was only after deciding that I would not only help folks with questions, but that I would also take action to at least minimize the rude things that people said to each other.

(See what happens when you say nice things to me? I get all emotional and start pouring out my innards! Smile )

Your words are very kind and they touched me deeply. (I'm gettin' misty again.) Thank you.


------------------
JPD





Quote Reply
Re: Multi-word file names without a "_" In reply to
I just realized a little improvement to what I gave you earlier.

You can put the code

Code:
$state = $db_setup;
$state =~ s/_/ /g;

right into the db.cgi script, just after

Code:
$in{'db'} ? ($db_setup = $in{'db'}) : ($db_setup = 'default');
$in{'uid'} ? ($db_uid = $in{'uid'}): ($db_uid = '');

This is assuming that you have separate .cfg files for each of the .db files.

The only problem is that, if you have a .cfg file called New_york.cfg, you will end up with New york. Capitalizing the second letter is going to be a challenge. I'll see what I can come up with.


------------------
JPD





Quote Reply
Re: Multi-word file names without a "_" In reply to
Greetings JPD,

Think no more on this matter - the information you supplied has been tested and works like magic. My file names were already correctly capitalized - now they are correctly punctuated as well.

Smile :>D

Thank you so very much for sharing those lines of biographical info and your concerns about forum decorum and civility.

You inspire us with your knowledge and patience, dear unseen friend!

David Anderson in TN

PS: I have a Carol, too. She writes:

Hey Carol,
I was reading over my husband's shoulder your helpful words to him about our Registry (database).

Isn't it the truth! that there are some ingrates out there who are very rude. Double whammy, no?

I would like to share with you some encouraging words that one Florence Littauer shared with me via audiotape. She was speaking to a group of children at a church meeting about letting our words be edifying to one another (that's Ephesians 4:29).

When she finished talking back and forth with the kids, one little girl stood up and looked at the rest of the congregation. As if acting as Florence's interpretur the girl said, "What she means is that our words should be like silver boxes with bows on top."

Isn't it so easy to "knock someone's blocks down" when a simple word or two of encouragement would have been (usually) so easy to have said?

Thank you again for your kindness, support, and the siver boxes, Carol. We love you!

Carol (ladycma@aol.com)