Format of data file using associative arrays?
key => ['item','item','item','item','item','item']
key => ['item','item','item','item','item','item']
key => ['item','item','item','item','item','item']
?? Is this what it should look like?
If so, how do I read from a file formatted like this.
I realize this should be fairly self-evident, however I can't get it through my head how to read in a data file in this format, nor if this is the correct way to write the data out?
Help would be very appreciated.
I have looked up O'Reilly's Learning Perl, the Perl Cookbook, and the IDG Perl for Dummies, and while they explain quickly how hashes and keys work, they don't address the saving to a data file, nor the reading from a data file, and that is, unfortunately, what I'm stuck on.
Thank you so much in advance,
Suzanne
Mark Hensler posted this at 06:22 — 15th February 2001.
He has: 4,048 posts
Joined: Aug 2000
nope... personally, I don't save stuff like that.
[file]
field1||field2||field3||field4||field5
field1||field2||field3||field4||field5
field1||field2||field3||field4||field5
[/file]
I use "||" (or something else...) to delineate my data in a flat file.
when reading, you need to loop through the lines (rows) in the file. Then split() the data into an array around "||" (or whatever your delimiter is).
#saving one line of data to file... (via append)
open (FILE, ">>my_file.txt");
print FILE "$field1||$field2||$field3||$field4||$field5\n";
close (ENTRIES);
#reading whole file, one line at a time...
open (FILE, "my_file.txt");
@my_file = <FILE>;
close (FILE);
#cycle through lines
foreach $line (@my_file) {
@data = split(/\|\|/,$line);
#$data[0] is field1
#$data[1] is field2
#etc.
}
Mark Hensler
If there is no answer on Google, then there is no question.
Suzanne posted this at 06:25 — 15th February 2001.
She has: 5,507 posts
Joined: Feb 2000
And if you do, how do you sort it out. I need to edit and delete specific lines in the data file, and I can't see a way to do that without using hashes and keys.
??
Suzanne
Mark Hensler posted this at 07:17 — 15th February 2001.
He has: 4,048 posts
Joined: Aug 2000
how is the file formated?
Suzanne posted this at 16:09 — 15th February 2001.
She has: 5,507 posts
Joined: Feb 2000
I need to write to the file the data I take in from a form, and I don't know what the right format is (above format is the recommended format *within* a script, but I can't seem to find anything on an external data file), and while I can write to a file that way, I don't know how to read from it (pull it into the script for editing/deletion) exactly.
Using the tab or | delimited flat file sort of thing is a problem because I can't pull out a line and *then return it*.
S
Mark Hensler posted this at 16:30 — 15th February 2001.
He has: 4,048 posts
Joined: Aug 2000
what do you mean by *return it*?
return it via a function?
or return it to the file?
Suzanne posted this at 16:48 — 15th February 2001.
She has: 5,507 posts
Joined: Feb 2000
Like pull it out, edit a portion of the list (using the key to identify it) and then return the changed data to the file.
I really need information on Hashes and using Keys. The rest of it isn't an issue, I'm very clear on _once I have the data_ using it.
The data is being input by someone else through a form, and I need them to be able to retrieve the data they entered, make modifications if necessary, and basically resave the data.
Therefore I need to use Associative Arrays. But I don't know how to write the data to the file, and I am not sure how best to read the data from the file back into the script.
I don't know any better way to ask this question!
S
Rob Pengelly posted this at 23:24 — 16th February 2001.
They have: 850 posts
Joined: Jul 1999
Sorry about the late response, I have been busy. Here is some code that will hopefully get you on your way.
test.txt currently contains:
hello|how|are|you|doing|today|
I|hope|I|find|you|feeling|healthy|
I'm|so|glad|our|paths|crossed|this|time|today|
On|our|way|into|the|night|
#!/usr/bin/perl -w
use strict;
my $file = 'C:\windows\desktop\test.txt';
my %foo = gethash($file); #gethash() will get contents of $file and put it in a hash
push(@{$foo{'3'}},"bleh"); #this is adding a new value to the last key
savehash($file,%foo); #savehash() saves %foo to $file
#the following code will loop through the hash and print.
foreach my $key(keys %foo)
{
for(my $i=0;$i<@{$foo{$key}};$i++)
{
print $foo{$key}->[$i]." ";
}
print "\n";
}
#outout:
#hello how are you doing today
#I hope I find you feeling healthy
#I'm so glad our paths crossed this time today
#On our way into the night bleh
sub gethash
{
my $file = $_[0];
my %hash;
my $i = 0;
open(IN,"<$file") or die "Cannot open $file to read: $!";
while(<IN>)
{
chomp $_;
my @data = split(/\|/,$_);
foreach(@data)
{
push(@{$hash{$i}},$_);
}
$i++;
}
return %hash;
}
sub savehash
{
my ($file,%hash) = @_;
open(IN,">$file") or die "Cannot open $file to read: $!";
foreach my $key(keys %hash)
{
for(my $i=0;$i<@{$hash{$key}};$i++)
{
print IN $hash{$key}->[$i]."|";
}
print IN "\n";
}
close(IN);
}
Now test.txt contains
hello|how|are|you|doing|today|
I|hope|I|find|you|feeling|healthy|
I'm|so|glad|our|paths|crossed|this|time|today|
On|our|way|into|the|night|bleh|
Hope that helps!
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
Suzanne posted this at 01:47 — 17th February 2001.
She has: 5,507 posts
Joined: Feb 2000
okay, that answers a whole bunch of questions I wasn't even sure I had, thank you so very much Rob.
I've only ever dealt with arrays, not associative arrays (hashes) and I confess that the reading made sense but I haven't touched Perl in about 8 months and suddenly I am in totally over my head.
*sigh*
But, yes, yes, this is very helpful. I very much appreciate you taking the time to answer my question with such a clear example.
Now to adapt it!
Thanks again, Rob,
Suzanne
japhy posted this at 08:05 — 17th February 2001.
They have: 161 posts
Joined: Dec 1999
Has it occurred to you to use the Data::Dumper module?
#!/usr/bin/perl -w
use Data::Dumper;
use strict;
my %sample = (
name => 'Jeff',
age => 19,
work => 'RiskMetrics',
);
open RECORD, "> path/to/record.txt"
or die "can't create path/to/record.txt: $!";
print RECORD Data::Dumper->Dump(
[\%sample],
['*sample'],
);
close RECORD;
Now, the path/to/record.txt file looks something like:
%sample = (
'name' => 'Jeff',
'work' => 'RiskMetrics',
'age' => 19
);
And all you need to do is read the file in and eval() it:
#!/usr/bin/perl -w
use strict;
my %sample;
open RECORD, "path/to/record.txt"
or die "can't read path/to/record.txt: $!";
{
local $/; # to slurp the file all at once
eval <RECORD>;
}
close RECORD;
print $sample{name}; # 'Jeff'
Hope this helps.
Suzanne posted this at 08:17 — 17th February 2001.
She has: 5,507 posts
Joined: Feb 2000
But I wasn't sure if it was part of the standard setup. I'll run perldiver and find out if I can use it.
I really do appreciate the responses, because I've been tearing out my hair trying to get this figured out. I've been wearing too many hats and I sure as hell am not a programmer.
Thank you very much, truly.
Suzanne
Edited to add: YES! It has the Data::Dumper module! Phew! This server is freely given, not supported, and has SSI/Perl/CGI and that's it.
THANK YOU!
[Edited by Suzanne on Feb. 17, 2001 at 04:09 AM]
Mark Hensler posted this at 09:53 — 17th February 2001.
He has: 4,048 posts
Joined: Aug 2000
japhy-
what's the file look like?
do you get to deliminate it yourself? or does it do a specific way?
I'm guessing that you formated the file using:
print RECORD Data::Dumper->Dump(
[\%sample],
['*sample'],
);
Mark Hensler
If there is no answer on Google, then there is no question.
japhy posted this at 15:32 — 17th February 2001.
They have: 161 posts
Joined: Dec 1999
The file looks something like:
%sample = (
'name' => 'Jeff',
'work' => 'RiskMetrics',
'age' => 19
);
That is, it looks exactly like a chunk of Perl code.
If you want to store multiple hashes, you can use references -- that is, make an array of hashes, or a hash of hashes.
Or, use a database, and have the values in the database be the output of the Data::Dumper->Dump(...) method.
And before you ask me how to use Data::Dumper->Dump(...), please note that it is a STANDARD module, so you already have it, so you can read its documentation. And if, for some reason, you don't, you can find it on CPAN, at the very least.
Suzanne posted this at 00:06 — 18th February 2001.
She has: 5,507 posts
Joined: Feb 2000
I just wanted to say thank you so much for letting us have access to your expertise. Sometimes all the reading in the world doesn't help as much as someone who knows what they are talking about answering a question.
That said, do correct me if I'm wrong, but for an associative array where the value is a list, it would look like the following?
%hash (
key => ['item','item','item','item','item','item'],
key => ['item','item','item','item','item','item'],
key => ['item','item','item','item','item','item']
);
(Obviously the keys would be unique.)
Would this be better than a hash of hashes, or worse? Or is that one of the "you can do in many ways in Perl" sort of things?
I do apologize for my lack of polish here, but as I said, it's been a long time since I played with Perl, and I am in far over my head with this project.
Suzanne
P.S. I don't have a database available.
japhy posted this at 00:13 — 18th February 2001.
They have: 161 posts
Joined: Dec 1999
You have at least access to at least ONE database -- the Any_DBM module is built-in to Perl, with support for at least SDBM_File.
And yes, a hash of array references looks like
%data = (
jeff => ['japhy', 19, 'RiskMetrics'],
anthony => ['anton', 20, 'RiskMetrics'],
# name => [$nick, $age, $workplace],
);
You might want to use a hash of hash references instead:
%data = (
jeff => {
nick => 'japhy',
age => 19,
work => 'RiskMetrics',
},
# etc.
);
Suzanne posted this at 00:22 — 18th February 2001.
She has: 5,507 posts
Joined: Feb 2000
Thank you!
I think of databases as huge monsters. I am off to read the documentation on the modules.
I like the hash of hash references, actually, I think that will meet my needs very nicely.
Thank you again, Japhy. Your responses are very helpful, and much appreciated. Like a clear glass of water after days alone in the desert!
S
Suzanne posted this at 22:57 — 28th February 2001.
She has: 5,507 posts
Joined: Feb 2000
Well, after repeated attempts to make it work, under all manner of conditions, I cannot achieve success.
Worse, I have no access to error logs, no telnet access, no way at all other than ftp and try it out, to see if it works. SO all I know is that I am getting 500 Internal Server Errors all over the place when I try to read the data file.
I'm so totally and completely frustrated! Argh!
Sample Data:
'0' => ['A Coastal Affair: Callaway Vineyards','April 2,
2001','Chartwell's at the Four Seasons Hotel','6:00
pm','9:00 pm','$99, only available through Chartwell's at
(604) 689-9333','Reception Style Food & Wine','Please join
Chef Anderson from the Four Seasons Hotel and winemaker John
Falcone from Callaway Vineyards for a wonderful evening of
the finest California coastal wines paired with the finest
culinary delights from the Pacific Northwest. This evening
promises to delight the senses and the palate.','','0'],
'1' => ['The Other 'Down Under'','April 2, 2001','Sweet
Obsession at Trafalgars','6:00 pm','9:00 pm','$95, only
available through Sweet Obsession at Trafalgars at (604)
739-0555','Formal Sit Down Food & Wine','In true Kiwi style,
experience an intimate evening featuring New Zealand wine
and food with a Canadian flair. Trafalgars chef Chris Moran
and pastry chef Tracy Kadonoff will create a truly Canadian
feast to pair with limited production New Zealand wines
showing the range of styles produced across both islands,
and from several wineries - Longridge, Stoneleigh,
Corbans.','','1'],
Sample Script allegedly reading above data
#!/usr/bin/perl -w
# this script prints a dropdown form allowing for the user to choose an event to edit
$header = "/u02/external/winefest/docs/includes/header.shtml";
$sidebar = "/u02/external/winefest/docs/includes/adminsidebar.shtml";
$features = "/u02/external/winefest/docs/includes/adminfeatures.txt";
$footer = "/u02/external/winefest/docs/includes/footer.txt";
# open the data file for reading, read it, put it away
my %events;
open (RECORD, "</u02/external/winefest/cgi-bin/allevents.dat") or die "eep eep $!";
{
local $/; # slurp it up
eval <RECORD>;
}
telling the browser what's coming
print "Content-type: text/html\n\n";
# test to make sure the darn thing is read
print "$events{'5'}[3]";
# make a new page displaying the options:
open(FILE,"$header") or die "can't open $header, $/";
while(<FILE>) {
print;
}
close(FILE);
open(FILE,"$sidebar") or die "can't open $sidebar, $/";
while(<FILE>) {
print;
}
close(FILE);
print "<td class=\"main\" rowspan=\"3\"
valign=\"top\">\n\n<h1>Edit an Event</h1>\n\n<h2>Choose an
event to edit</h2>\n\n<form name=\"festivallist\"
action=\"/cgi-bin/festivaleventseditform.cgi\"
method=\"post\">\n\n<select name=\"list\">\n\n";
@keys = keys %ENV;
@values = values %ENV;
foreach $key {
print the form insides, with the keys as the option values
print "<option value=\"$key\">$events{'$key'}[0]\n";
}
open(FILE,"$features") or die "can't open $features, $/";
while(<FILE>) {
print;
}
close(FILE);
open(FILE,"$footer") or die "can't open $footer, $/";
while(<FILE>) {
print;
}
close(FILE);
exit;
What the heck am I doing wrong? I'm so lost.
Suzanne
Edited to stop the scroll - I don't have new lines breaking up the data, et cetera.
[Edited by Suzanne on Feb. 28, 2001 at 07:13 PM]
japhy posted this at 23:08 — 28th February 2001.
They have: 161 posts
Joined: Dec 1999
Ok, the problem is that you my() the hash in the main program. That should be all it is.
On another note, I realized you can just say:
do "filename";
# or
require "filename";
instead of slurping the file and eval()ing it.
Suzanne posted this at 00:11 — 1st March 2001.
She has: 5,507 posts
Joined: Feb 2000
Okay, I did , but still nothing is being read from the hash. I have never wanted to see an error file so bad in my life. I so appreciate you eyeballing the code. *argh*
In case I have screwed up a few more things...
#!/usr/bin/perl -w
# this script prints a dropdown form allowing for the user to choose an event to edit
$header = "/u02/external/winefest/docs/includes/header.shtml";
$sidebar = "/u02/external/winefest/docs/includes/adminsidebar.shtml";
$features = "/u02/external/winefest/docs/includes/adminfeatures.txt";
$footer = "/u02/external/winefest/docs/includes/footer.txt";
# open the data file for reading, read it, put it away
%events;
open (RECORD, "</u02/external/winefest/cgi-bin/allevents.dat") or die "eep eep $!";
# tried do "allevents.dat" as well
{
do "/u02/external/winefest/cgi-bin/allevents.dat";
}
telling the browser what's coming
print "Content-type: text/html\n\n";
# see if something is coming out of the hash
print "$events{5}[3]";
# make a new page displaying the options:
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>
WineFestival Admin Edit Events</title><meta
name=\"ProductionSpecialist\" content=\"Suzanne Carter-
Jackson\"><meta http-equiv=\"Content-Type\"
content=\"text/html; charset=ISO-8859-1\"><meta
name=\"keywords\" content=\"wineries wine international
company italy spain germany france australia canada us
europe\"><meta name=\"description\" content=\"Participating
Wineries for the Vancouver Playhouse's International
WineFest\"><meta http-equiv=\"Content-Style-Type\"
content=\"text/css\"><link rel=\"stylesheet\"
type=\"text/css\" href=\"/styles/default.css\"></head><body
marginheight=\"0\" marginwidth=\"0\">";
open(FILE,"$header") or die "can't open $header, $/";
while(<FILE> {
print;
}
close(FILE);
open(FILE,"$sidebar") or die "can't open $sidebar, $/";
while(<FILE> {
print;
}
close(FILE);
print "<td class=\"main\" rowspan=\"3\" valign=\"top\">\n\n<h1>Edit an Event</h1>\n\n<h2>Choose an
event to edit</h2>\n\n<form name=\"festivallist\"
action=\"/cgi-bin/festivaleventseditform.cgi\" method=\"post\">\n\n<select name=\"list\">\n\n";
# @keys = keys %ENV;
# @values = values %ENV;
# foreach $key {
#print the form insides, with the keys as the option values
# print "<option value=\"$key\">$events{'$key'}[0]\n";
# }
open(FILE,"$features") or die "can't open $features, $/";
while(<FILE> {
print;
}
close(FILE);
open(FILE,"$footer") or die "can't open $footer, $/";
while(<FILE> {
print;
}
close(FILE);
print "</body></html>";
exit;
japhy posted this at 00:35 — 1st March 2001.
They have: 161 posts
Joined: Dec 1999
But what does the allevents.dat file look like? If you want to access the contents in it as the %events hash, you need to create that file by doing:
use Data::Dumper;
%hash = (...);
open OUTPUT, ">allevents.dat";
print OUTPUT Data::Dumper->Dump([ \%hash ], ['*events']);
close OUTPUT;
That will create a properly formatted file for reading:
do "allevents.dat"; # no need to open the file
Suzanne posted this at 02:31 — 1st March 2001.
She has: 5,507 posts
Joined: Feb 2000
Sample data is a few posts up. See the problem is the data already exists, so it has to be in the right format, right?
*sigh*
The data is created through a form, so I have to write the format of the hash (right?), which I have done, which is...
'key' => ['item0','item1'],
I have removed all new lines and returns from text areas (using $variable =~ s/\r//g; et cetera), and I replaced all single quotes with \' as well.
What the heck am I missing?! I can't get data::dumper to work at all, either, btw, same thing -- constant 500 internal server errors, even when I used your code that you gave me earlier. I know I must be doing something totally daft, but I just can't see it.
Suzanne
'0' => ['A Coastal Affair: Callaway Vineyards','April 2,
2001','Chartwell's at the Four Seasons Hotel','6:00
pm','9:00 pm','$99, only available through Chartwell's at
(604) 689-9333','Reception Style Food & Wine','Please join
Chef Anderson from the Four Seasons Hotel and winemaker John
Falcone from Callaway Vineyards for a wonderful evening of
the finest California coastal wines paired with the finest
culinary delights from the Pacific Northwest. This evening
promises to delight the senses and the palate.','','0'],
'1' => ['The Other 'Down Under'','April 2, 2001','Sweet
Obsession at Trafalgars','6:00 pm','9:00 pm','$95, only
available through Sweet Obsession at Trafalgars at (604)
739-0555','Formal Sit Down Food & Wine','In true Kiwi style,
experience an intimate evening featuring New Zealand wine
and food with a Canadian flair. Trafalgars chef Chris Moran
and pastry chef Tracy Kadonoff will create a truly Canadian
feast to pair with limited production New Zealand wines
showing the range of styles produced across both islands,
and from several wineries - Longridge, Stoneleigh,
Corbans.','','1'],
[Edited by Suzanne on Feb. 28, 2001 at 09:43 PM]
Mark Hensler posted this at 08:36 — 1st March 2001.
He has: 4,048 posts
Joined: Aug 2000
add CGI::Carp qw(fatalsToBrowser); near the top (2nd line)
what does it say now?
Suzanne posted this at 17:14 — 1st March 2001.
She has: 5,507 posts
Joined: Feb 2000
"Server Error
This server has encountered an internal error which prevents it from fulfilling your request. The most likely cause is a misconfiguration. Please ask the administrator to look for messages in the server's error log."
*sigh*
Further edits and now it says:
Bad name after pm:: at /u02/external/winefest/cgi-bin/allevents.dat line 16.
And it *still* isn't reading the hash.
Edit #2: Okay, fixed the error in the data in the allevents.dat file (missing a \' had a ' instead)... So the page is working perfectly except for the most important part -- it's not reading the data, it seems.
Thank you Matt, for this help, truly. I am now specifically instead of globally frustrated!
Suzanne
[Edited by Suzanne on Mar. 01, 2001 at 05:59 PM]
Suzanne posted this at 23:13 — 1st March 2001.
She has: 5,507 posts
Joined: Feb 2000
This is what I am getting as generated (a portion)!
<option value="SERVER_SOFTWARE">
<option value="Netscape-Enterprise/2.01d">
<option value="GATEWAY_INTERFACE">
<option value="CGI/1.1">
<option value="REMOTE_ADDR">
<option value="154.5.152.106">
<option value="SERVER_PROTOCOL">
<option value="HTTP/1.1">
<option value="REQUEST_METHOD">
<option value="POST">
<option value="REMOTE_HOST">
<option value="154.5.152.106">
<option value="SERVER_URL">
Oh boy.
At least I know where the problem is... *sigh*
S
Edited to add: I have it so it isn't doing this now, however... Now it isn't printing anything, it doesn't seem to be reading the information from the dat file (but no more errors, just blankness).
Help!
[Edited by Suzanne on Mar. 01, 2001 at 06:30 PM]
Suzanne posted this at 00:18 — 2nd March 2001.
She has: 5,507 posts
Joined: Feb 2000
Here's the deal...
The information for the hash comes in through a form, but I can't write this:
%hash = ($name => [$id,$country,$table,$wines,$details,$rep,$repphone,$web]);
open OUTPUT, ">>allwineries.dat";
print OUTPUT Data::Dumper->Dump([ \%hash ], ['*wineries']);
close OUTPUT;
Because then I get this:
%wineries = (
'Suzannec' => [
'SDGON',
'Canada',
65,
'asdfasd<br>asdf<br>asd<br>asdf<br>asdf<br>asdgadpogjasdg<br>',
'asldfjo;isau asdlk ouasek glkoiuw nlkwlia gnklu obual.',
'Vancouver BC',
'Vancouver BC',
'http://www.somethingorother.com'
]
);
%wineries = (
'Suzanne' => [
'SDGYYON',
'Canada',
65,
'asdfasd<br>asdf<br>asd<br>asdf<br>asdf<br>asdgadpogjasdg<br>',
'asldfjo;isau asdlk ouasek glkoiuw nlkwlia gnklu obual.',
'Vancouver BC',
'Vancouver BC',
'http://www.somethingorother.com'
]
);
Which is obviously not what I want in there.
So I have data::dumper working (thank you again, Japhy), but not quite as intended. How do I use it to ADD keys to the hash? This is just so frustrating!!!
Suzanne
japhy posted this at 00:22 — 2nd March 2001.
They have: 161 posts
Joined: Dec 1999
use Data::Dumper;
# first, read in the hash from the file:
do "allwineries.dat"; # creates %wineries
# then, modify it
$wineries{$newuser} = [ ... ];
# then, save it
open OUT, "> allwineries.dat";
print OUT Data::Dumper->Dump([\%wineries], ['*wineries']);
close OUT;
Suzanne posted this at 00:42 — 2nd March 2001.
She has: 5,507 posts
Joined: Feb 2000
I can't believe how wonderfully helpful you have been.
The data is writing perfectly to the data file now.
I am going to "fix" the allevents.dat file and see if I can get it to read it properly.
If you have a wishlist and/or a website, please let me know!
Suzanne
japhy posted this at 00:51 — 2nd March 2001.
They have: 161 posts
Joined: Dec 1999
I recently revamped my web site with CSS. It looks quite spiffy in my opinion.
I keep track of my important Perl work there. The latest thing I've added is the OGRE program. Soon to be added is a link to my "The Perl Conference 5.0" presentation on "Reverse Perlish Notation".
Imagine writing the code I showed you before:
use Data::Dumper;
# first, read in the hash from the file:
do "allwineries.dat"; # creates %wineries
# then, modify it
$wineries{$newuser} = [ 1,2,3 ];
# then, save it
open OUT, "> allwineries.dat";
print OUT Data::Dumper->Dump([\%wineries], ['*wineries']);
close OUT;
in RPN:
Data::Dumper use;
# first, read in the hash from the file:
"allwineries.dat" do; # creates %wineries
# then, modify it
wineries$ newuser${} 1, 2, 3[] =;
# then, save it
OUT, "> allwineries.dat" open;
OUT Data::Dumper wineries%\[], '*wineries'[] Dump -> print;
OUT close;
Yes, it looks hideous to you now, but wait until the presentation contents have been created (and completed), and then the specifications will be perfectly clear...
Suzanne posted this at 01:59 — 2nd March 2001.
She has: 5,507 posts
Joined: Feb 2000
Totally over my head, yes!
But I will get there.
In this project I have learned about 700x more than I even thought I could learn, not that I'm any risk to Perl professionals, but I am a little more confident about how to *approach* a project, if nothing else.
***
Okay, we have reading!! YAY!
However...
@keys = keys %events;
@values = values %events;
foreach $key (%events) {
# print the form insides, with the keys as the option values
print "<option value=\"$key\">Event: $events{'$key'}[0]\n";
}
Returns this:
<option value="11">Event: Bacchanalia Gala Dinner & Auction
<option value="ARRAY(0x12dc98)">Event:
<option value="30">Event: Trade Event (Buyers & Servers)<br>To Pair or Not to Pair California Style
<option value="ARRAY(0x133380)">Event:
<option value="12">Event: California Vino-A-Go-Go
<option value="ARRAY(0x12dd28)">Event:
<option value="31">Event: Trade Event (Consumer & Trade)<br>California Vino-A-Go-Go
<option value="ARRAY(0x13502c)">Event:
Hunh?
Suzanne (who is so happy right now to anything at all, she's kind of loopy)
Suzanne posted this at 02:31 — 2nd March 2001.
She has: 5,507 posts
Joined: Feb 2000
Okay, I fixed it! All by myself (and 7 books, ha ha)...
# @keys = keys %events;
@allkeys = keys %events;
foreach $key (@allkeys) {...}
WHEE!
And I even sort of understand it, for pete's sake. *ah*
Thank you very much Japhy, for getting me over this hurdle. Now to finish the blinking script! THANK YOU!
Suzanne
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.