I'm running Perl 5.x on a Debian GNU/Linux system here, and wrote a simple script last night to normalize hundreds of filenames for me. A minor issue I've run into is with defining a directory path for the script to use. A snippet of relevant example code follows (slightly modified so that it makes sense without the rest of the script):

my $direct; chomp($direct = $ARGV[0]); chdir($direct);

Basically, this script as currently written forces me to use absolute paths, whereas I'd like to make it use relative paths. Best would be path relative to where I am in the filesystem when I run it, but it won't even recognize relative path from the location of the script, which just boggles my mind. What am I missing?

I've done searches at PerlMonks, looked through several books (including Visual Quickstart: Perl and CGI for the World Wide Web, the llama, and Perl in a Nutshell), and browsed through online tutorials, but haven't discovered anything particularly helpful on the matter.

- apotheon
CopyWrite Chad Perrin

In reply to working with relative paths by apotheon

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.