I have am building my first app in perl and I'm having a hard time making it work properly. I would like to have the information saved to the clients folder and when they return to the page, the fields that they filled in should still show as saved in the browser. Also, I'd like the files to upload to the company repository. I have a working page I'm using as a template but when I try to edit it, it just won't work. Here's the script...
#!/usr/bin/perl ################################################################ ######################################################## sub valid_cookie{ $flag=0; my $session_file=$companyrepository."/session.txt"; #file where se +ssions are stored unless(open(INTT, "$session_file")){print "Session not found $sess +ion_file. $cookie<br>";} while (<INTT>){ #find existing cookie if($_=~/^$cookie\;/){#if cookie exist $flag=1; last; } } close INTT; return $flag; } ###################################################################### +###### sub writeData { unless(open (OUT,">>".$companyrepository."/PO.txt")){ open (OUT, ">".$companyrepository."/PO.txt"); } print OUT "$write_data\n"; close (OUT); } ###################################################################### +###### sub readData { if (-e $datafile) { open (IN,"<".$datafile); while (<IN>) { push @values, $_; } close (IN); } } ###################################################################### +###### use CGI; $query = new CGI; $repository="/home/warp/userdata/"; #$flag2=0; #init flag for existing users ####check for valid cookie#### $cookie=""; @temp=""; $cookie=$ENV{'HTTP_COOKIE'}; #identify cookie @temp_cookie=split(';',$cookie); $cookie=$temp_cookie[0]; ($sess_id,$company,$site,$user)=split('%2C', $cookie); $companyrepository=$repository.$company."/".$site; valid_cookie(); # If cookie not valid, then redirect to login page if ($flag==0){print $query->redirect('http://services.genband.com/cgi- +bin/dbq/na/DBQ_welcome.cgi'); }#redirect to another location $answer=$query->param("answer"); print "Content-type: text/html\n\n"; foreach $paramname ($query->param) { $formcomplete=1; #$paramcount++; $paramvalue=$query->param($paramname); $$paramname=$paramvalue; # preserve ratearea names if($paramname =~ /^sub/){ # read in subject chomp $$paramname; $write_data="$${paramname}:::"; }elsif($paramname =~ /^com/){ # read in PO chomp $$paramname; $com=$$paramname; $write_data=$write_data."$$paramname"; }elsif (($paramname eq "answer") && ($answer eq "finish")) { $finished=1; } } # create company specific variables $datafile=$companyrepository."/PO.txt"; $master_file=$companyrepository."/master_grpnum.txt"; ################################ # start html $header_file = "header5.html"; open(FILE,"$header_file"); while(<FILE>) { print $_; } close FILE; print <<'ENDHTML'; <tr> <td width="1020" bgcolor="#f4f4f4" align="center"> <table width="900" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#232021" height="25px" width="499" align="left" valig +n="bottom"><p class="h1">Project Overview</p></td> <tr><td colspan="2" bgcolor="#ffffff"><div id="container"> ENDHTML $datafile="$companyrepository/PO.txt"; if ($finished){ writeData; print "<p class=status>"; print "The Project Overview has been saved. <br>Choose your region + to continue<br><I>Note: Any location other than North America is considered International</I></p>"; print "<p class=status><button type=button type=button type=button + type=button onclick=\"window.location='http://services.genband.com/c +gi-bin/dbq/na/home.cgi'\">North American Database Questionnaire</butt +on> <button type=button type=button type=button type=button onclick=\"wind +ow.location='http://services.genband.com/cgi-bin/dbq/int/home.cgi'\"> +International Database Questionnaire</button></p>"; }else{ print "<form action='PO.cgi' method='post'>"; if (-e $datafile){ } print "<br>"; $cnt=1; foreach $v (@values){ @com=split(/:::/, $v); print "<b>$cnt. $com[0]</b><br>$com[1]<br><br>"; $cnt++; } $paramname='txt1'; print "<p class=status><b>Application</b> <i>(check all that apply +)</i><br></p>"; $paramname='app'; print "<p class=status><INPUT TYPE=CHECKBOX NAME='app' VALUE=appcl +ass4> Class 4 - trunk to trunk tandem calls only </p>"; print "<p class=status><INPUT TYPE=CHECKBOX NAME='app' VALUE=appcl +ass5> Class 5 - station to staion, station to trunk, trunk to staion +only </p>"; $paramname='type'; print "<p class=status><br><b>Type of Install</b><br><br><SELECT N +AME='type'> <OPTION SELECTED>Greenfield - new switch, no existing customer base pe +r say</OPTION> <OPTION>Cap and Grow - subtend and existing sysytem and provide growth + Capacity</OPTION> <OPTION>Migration - replace an existing system</OPTION> </SELECT><br><br></p>"; print "<p class=status> <form action='/home/warp/userdata/$companyrepo +sitory' method='post' enctype='multipart/form-data'> </p>"; print "<p class=status><b>Network Diagram:</b><br><br><input type=file + name='network_diagram' /></p>"; print "<p class=status><i>Present the node to be provisioned and show +all connections to external nodes.<br /> Other SP's, STP's, VMS, Servers or Remote Hosts.</i><br><br></p>"; print "<p class=status> <form action='/home/warp/userdata/$companyrepo +sitory' method='post' enctype='multipart/form-data'> </p>"; print "<p class=status><b>Call Flow Models: </b><br><br><input type=fi +le name='call_flow_models' /></p>"; print "<p class=status><i>Povide high level and detailed information.< +/i></p>"; ###################################################################### +##################################### # initial presentation of the page if ((!$formcomplete) && ($error eq "")) { print "<p class=status>"; print "<input type=submit name=answer value=finish>"; print "</p>"; # errors found when processing }elsif((!$formcomplete) && ($error ne "")){ print "<p class=status>"; print "<input type=submit name=answer value='re-submit'>"; print "<button type=button type=button type=button type=button + onclick=\"window.location='home.cgi'\">"; print "cancel</button><p class=main>$error</p>"; print "</p>"; # form has been completed without errors }elsif ($formcomplete) { print "<p class=status>"; print "<input type=submit name=answer value=finish>"; print "</p>"; } print "</form>"; } print <<'ENDHTML'; </div> </td></tr> </table> </td></tr> <tr> <td colspan="4" height="25px" bgcolor="#f4f4f4"></td> </tr> <tr> <td colspan="4" height="25px" bgcolor="#F0251A"><p class="h2">&nbs +p;</p></td> </tr> ENDHTML $footer_file = "footer1.html"; open(FILE,"$footer_file"); while(<FILE>) { print $_; } close FILE;

In reply to PLEASE Help with this script by ksolomon

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.