Before you get assaulted by the CGI.pm police (Update: too late! :-), here's what you should really be doing up front:
#!/usr/local/bin/perl -wT use strict; use CGI; my $q = CGI->new(); print $q->header(); # Using CGI is even easier than doing it yourself, # so PLEASE(!) use it! $studentid = $q->param('studentid'); $CSC = $q->param('CSC'); chomp($CSC); $assignment = $q->param('assignment'); $file = $q->param('file');
Now, consider constructing a path from variables, such as you are trying to do. Instead of using string interpolation, such as "$HOME/$x/$y", you should just join:
my $path = join ('/', $HOME, 'classes', $CSC, $studentid, $assignment, 'outputfile.txt');
Of course, before you even think of doing this, you must validate your parameters to make sure they are "kosher". Using 'perl' with the '-T' parameter makes user data tainted, or icky, and your program will fail with errors unless you check them out first.
# An example of "validated" input my ($studentid) = $q->param('studentid') =~ /(\w+)/;
You should define your input specification as narrow as possible. For example, if you just wanted numbers, you can use '\d+'. If none of this makes any sense, a quick browse through the regular expressions reference will help immensely. This is time well spent.

You should note that CGI.pm helped you by:

In reply to Re: Using Variables in Path Names by tadman
in thread Using Variables in Path Names by lfindle

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.