Hello ,
I am having a lot of trouble getting this script to run correctly. The if statement on line 47 does not see the $currentvariable. Is this related to the errors below?

I would appreciate any help. Thanks

The script is called from a submission form, using these four parameters. When I run this I get errors on all the lines using param:
my $writer = param{'writer'};
my $title = param{'title'};
my $text = param{'text'};
my $current = param{'current'};
Odd number of elements in hash assignment at reflections.cgi line 11 Odd number of elements in hash assignment at reflections.cgi line 12 Odd number of elements in hash assignment at reflections.cgi line 13 Odd number of elements in hash assignment at reflections.cgi line 14
<--- START SCRIPT -->
#!/usr/local/bin/perl -w use strict; use diagnostics; use CGI qw(:standard); my $cgi = new CGI; my $old_writer; my $old_title; my $old_text; my $writer = param{'writer'}; my $title = param{'title'}; my $text = param{'text'}; my $current = param{'current'}; my $html_file ="reflections.txt"; #this filename holds the $reflection_holder variable for finsh_events. +cgi my $data_file ="reflections.dat"; #this filename holds the $data_holder variable for manipulation my $data_holder = "$writer :: $title :: $text"; #this hold the reflection in a data form with "::" delimiters my $reflection_holder ="$writer <BR><BR><Font color=green>$title</font +> <BR> <br><Font face=Verdana, Arial, Helvetica, sans-serif size=1>$t +ext</font>"; #this holds the reflection in an html format #archive_holder holds the archive reflection html format my $archive_holder = " <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=windows-12 +52'> <meta name='GENERATOR' content='Microsoft FrontPage 4.0'> <meta name='ProgId' content='FrontPage.Editor.Document'> <title>Reflections</title> </head> <body bgcolor=#ffffff> <p><font face='Book Antiqua' color='#b5a466' size='5'>Reflections</fon +t></p> <p><font face='Book Antiqua' size='2'><font color='#B5A466'>by</font>& +nbsp; $writer </font></p> <p><font size='2'>$title</font></p> <hr> <p><font SIZE='2'>$text <P> <P></font></p> </body> </html>"; print "Content-type: text/html\n\n"; if ($current eq "ON") { print "<HR><B>This is what will be posted on the Reflections section o +f the homepage.</b><HR>\n"; print "by $writer<BR><BR>\n"; print "<Font color=green>$title</Font><BR><BR>\n"; print "$text<HR><br><br>\n"; #$text is actually the variable that con +tains the reflection #READ IN the old reflection data file before overwriting so it can be +archived open(FILE,"$data_file"); my @old_reflection=<FILE>; close FILE; foreach my $i (@old_reflection) { chomp($i); ($old_writer,$old_title,$old_text) = split(/\ :: /,$i); # this is the same as $count = $count + 1; my $count++; } my $the_title = "$old_title.shtml"; #current_holder holds the current reflection in html format for archiv +ing my $current_holder = " <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=windows-12 +52'> <title>Reflections</title> </head> <body bgcolor=#ffffff> <p><font face='Book Antiqua' color='#b5a466' size='5'>Reflections</fon +t></p> <p><font face='Book Antiqua' size='2'><font color='#B5A466'>by</font>& +nbsp; $old_writer</font></p> <p><font size='2'>$old_title</font></p> <hr> <p><font SIZE='2'> $old_text<P> <P></font></p> </body> </html>"; #print "<br><br> $current_holder <BR><BR>\n"; #store current reflections in archive open (FILE, "+> ../../../reflections/archive/$the_title"); print FILE "$current_holder\n"; close FILE; #create new reflection text file open (FILE, "+> $html_file "); print FILE " $reflection_holder\n"; close FILE; #create new reflection data file open (FILE, "+> $data_file "); print FILE "$data_holder\n"; close FILE; print "<FORM action=/cgi-local/homepage_update/events/finish_events.cg +i method=post><input type='submit' value='Submit' name='reflections'> +</form>\n"; } else { #store just entered reflection in Archive for later use print "This will be stored in the Archive until it is used\n"; open (FILE, "+> ../../../reflections/archive/$title.shtml "); print FILE "$archive_holder\n"; close FILE; }

In reply to If statement wont branch by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.