First, consider <CODE> tags instead of <PRE>. It word wraps.

If I understand you correctly, you don't want perl to interpret what you're writing to the file. In that case, use single quotes (') instead of double-quotes ("). You may also want to use something like <<EOF to write a bunch of output.

Here's what your code may end up looking like:

#####Create Perl upload script open(FILE, ">$basedir$q_brieftitle/upload.cgi") || &diedebug("$header Could not create file " . "$basedir$q_brieftitle/upload.cgi: $! . " . "It's possible that your web server will not " . "let me create files even if I own the directory. " . "If you have chmodded $basedir$q_brieftitle/ " . "to 777 and you are still getting this message, " . "then you will need to create your quizzes and " . "answerfiles by hand. :( $footer"); flock(FILE, 2); &get_date; # Note the single quotes in the next line... print FILE <<'EOF'; #!/usr/bin/perl $basedir = "/home/sites/stuff/users/web/up2"; $allowall = "yes"; $theext = ".gif"; $donepage = "http://www.yourpage.com/"; ## DO NOT EDIT OR COPY BELOW THIS LINE ## use CGI; $onnum = 1; while ($onnum != 11) { my $req = new CGI; my $file = $req->param("FILE$onnum"); if ($file ne "") { my $fileName = $file; $fileName =~ s!^.*(\\|\/)!!; $newmain = $fileName; if ($allowall ne "yes") { if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext){ $filenotgood = "yes"; } } if ($filenotgood ne "yes") { open (OUTFILE, ">$basedir/$fileName"); print "$basedir/$fileName"; while (my $bytesread = read($file, my $buffer, 1024)) { print OUTFILE $buffer; } close (OUTFILE); } } $onnum++; } print "Content-type: text/html\n"; print "Location:$donepage\n\n"; EOF close(FILE);

Cheers,
Shendal

In reply to Re: CGI Question by Shendal
in thread CGI Question by koacamper

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.