This is why I don't program while I'm tired. Path to the file was off.
Maybe this is a good place to add the comment that it's probably a good idea to tighten up the requirements for what you're going to allow as user input.

For example, you might do something like this:

sub untaint_directory { # restrict directory names to a short list of accessible locations my $var = $_[0]; my @allowed_locations = qw( political_babble funny_animal_stories down_with_starwars guests tests public ); my $dir; my $ok = 0; if ( ($dir) = ($var =~ m/^(\w+)$/ )) { foreach my $loc (@allowed_locations) { if ($dir eq $loc) { $ok = 1; last; } } } unless ($ok) { die("Not an allowed directory: $dir"); } return $dir; }
The idea is that this is a security related task, and you should be as paranoid about it as you can. Do your best to restrict the input you're going to accept to things that you know are okay.

In reply to Is restricting to "words" good enough? by doom
in thread -T switch & untaint - how to resolve errors? by Stenyj

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.