CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Is an array needed here?



Jan 17, 2003, 11:48 AM

Post #1 of 3 (552 views)
Is an array needed here? Can't Post

I am able to capture data from a form and send it to a text file. What I would like for the PERL Script to do is go through say 100 customer names. IF that customer name is picked I want it to go to that customers particular text file. Ex. Mary places an order. Her info goes to Mary.txt. Joe places an order. His info goes to Joe.txt. Right now I have all customers going to one text file. Do I need an array for something like this; to cycle through a bunch of customer names and send it to that customers file when it is entered in the form? Only Here is my current code for all customers going to 1 text file:

foreach $ab (@gold) {
$ri=~tr/+/ /;
print "Content-type: text/html\n\n";
@days = ("Sunday","Monday","Tuesday","Wednesday","Thursday",
@months = ("January","February","March","April","May","June",
($sec,$min,$hr,$mday,$mon,$year,$wday,$yday,$isdst) =
$year = $year + 1900;
print TECH
Service provided on $days[$wday], $months[$mon] $mday, $year, $timey:$timei:$timee&
The Account name is $Regis{ACCOUNT}&
The Description is $Regis{DESCRIPTION}&
The Items sold are $Regis{AMOUNT}&
print qq ~CLICK HERE(<A href="">OFFICEINDEX.HTML</A>)~;


Jan 17, 2003, 12:55 PM

Post #2 of 3 (549 views)
Re: [axaflaxar] Is an array needed here? [In reply to] Can't Post

First of all: It's safer to use than fiddling with the query string yourself.

If I understood you correctly, then you don't need an array at all, just write to the file with the username that was given by the parameter. But if you really need to verify that name against a list of costumers, it would be faster to have a hash with the costumer names as keys. That way you could check if the given name is a valid one (like if (exists $costumers{$name}) { ... }).

PS: Just out of curiosity: What are those "&" characters for in the string you print out?


Jan 18, 2003, 2:39 AM

Post #3 of 3 (547 views)
Re: [axaflaxar] Is an array needed here? [In reply to] Can't Post

Also use error checking on your open()


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives