I have a script that creates a webpage (its content & name are be based on what was selected in the previous form). The problem I am having is that the script refuses to create the file in a separate directory, no matter how I try. I have resorted to moving the file once it is created, but that isn't working either. I have left my attempts in the code as comments so that you can see what I have already tried. Any help is appreciated, even if you see something that isn't related that could be improved!
#!/usr/bin/perl -w use warnings; use CGI; #use File::Copy; my($buffer) = ""; my($firstChoice) = ""; my($secondChoice) = ""; my(@values) = ""; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); (@values) = split(/&/, $buffer); $firstChoice = $values[0]; $secondChoice = $values[1]; ($NULL, $firstChoice) = split(/=/, $firstChoice); ($NULL, $secondChoice) = split(/=/, $secondChoice); #print "Content-type: text/plain\n\n"; #print "$firstChoice\n"; #print "$secondChoice"; my($dynamic) = "$firstChoice$secondChoice.html"; open (FH, "+>" . $dynamic); print FH "<html>\n"; print FH " <head>\n"; print FH " <title>$firstChoice and $secondChoice</title>\n"; print FH " </head>\n"; print FH " <body>\n"; print FH " You chose $firstChoice and $secondChoice\n"; print FH " </body>\n"; print FH "</html>\n"; close (FH); #These are all of the ways that I have tried to move the file and fail +ed: #1: #rename "$dynamic", "dynamics/$dynamic"; #2: #system("mv $dynamic dynamics/"); #3: #my($original_file) = "$dynamic"; #my($new_file) = "dynamics/$dynamic"; #move($original_file, $new_file); print "Location: dynamics/$dynamic\n\n";

In reply to Moving a .html file by Sam_07

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.