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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For loop troubles

Status
Not open for further replies.

sulfericacid

Programmer
Aug 15, 2001
244
US
I was told you can't do prints with a for loop which would explain why I am getting an error on the line I am trying to print the keys of my database. Can anyone help me get these keys to print?

#!/usr/bin/perl -w

use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);

require SDBM_File;
use POSIX;

use CGI qw/:standard/;
my $query = CGI->new;
my %form = $query->Vars;
my $dbm = "poems.dbm";

tie( my %dbm, 'SDBM_File', $dbm, O_CREAT | O_RDWR, 0644 )
|| die "Died tying database\nReason: $!\n";

if ( $form{'poemtitle'} && $form{'poemsub'} ) {

$dbm{ $form{'poemtitle'} } = $form{'poemsub'};

print header(), start_html('Success'),
&quot;Your poem entitled <b>$form{'poemtitle'}</b> has been added\n&quot;,
end_html();
}
else {
print header(), start_html('Poetry Submissions'),

#########
for ( sort keys %poemtitle ) {
print $_;
}

start_form, &quot;Submission Title&quot;, textfield('poemtitle'), p, &quot;Submission&quot;,
textarea(
-name => 'poemsub',
-rows => 10,
-columns => 50
),
submit, end_form, hr, end_html();
}
&quot;Age is nothing more than an inaccurate number bestowed upon each of us at birth as just another means for others to judge and classify us- sulfericacid
 
i don't see where the hash %poemtitle gets declared, defined, or assigned-to. in fact the only reference i see to poemtitle is as a key to the %form hash. perhaps you should be using 'keys %dbm' instead?

jaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top