Possibly OT, but I see a possibility that you need to rethink your question... or, at least, the title portion and some matters which grow out of that.

My surmise is based in part on your comment "I really need to be able to determine where the perl script was executed from..." and in part on what I see as the implication ( in your observation that CWD and CGI report the location as "/." ) that you don't want to save the uploads there. (Also note that the directory from which perl executes and the cgi-bin where your script is stored are not necessarily the same, and may well involve all manner of sym link magic, which is far beyond the scope of this discussion.)

So if you're really looking for answers about how to find and define an appropriate target for uploads, consider this: they might go to a subdirectory of cgi-bin such as /uploads/ *OR* to an .hta-protected directory within your /http-docs/ (or /public-html/ or /http-public/ or /whatever-name/ the admin of your server has defined as the public root -- the highest level directory browseable by the general public).

If you use a protected subdir of /http-docs/, you should be able to give your script a full URL to that subdir; eg "http://www.foo.bar/blivitz/" and append a filename supplied by the user (after some cautious untainting). You probably do NOT want to save the uploads in any directory to which access is otherwise available to the uploader -- simply because it makes some mischief easier.

Alternately (and still hypothesizeing that you're on a shared Apache or similar *nix server from which I've also inferred that you are NOT the admin of the server and that you do not have root priviledges) you might explore your site's root directory -- *EMPHASIS* on "your site's root" because that and the actual root are not the same. Even a simple tool like your ftp client can be used to check your site's root. Many providers will offer a directory named "ftp" or similarly, with a subdir called "incoming" or "uploads" or somesuch. If so, aiming your users' files at /ftp/uploads/ can be an answer to the question I have so brashly hypothesized to be your real issue.


In reply to OT: Non-perl -- but question may be the wrong question by ww
in thread Using FindBin or CWD from within a CGI program by smack

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.