For starters, you're opening the file '$control_file' before assigning anything to that variable, so it's empty. If you 'use warnings', it'll tell you about that. Plus, since you've got single quotes inside double quotes, you actually get a file named with two single quotes. Probably not what you want.

Because you open the control file outside your loop, I'm not sure whether you want a single file containing a list of names created from all your PDF files (what your code seems designed to try to do), or a different control file to match each PDF (what your description sounds like). Can you clarify?

Edited to add: Upon re-reading, it appears that you want a single control file, named after the "first" file found in the directories. (Whether you want the first one alphabetically, or by age, or by some other sorting factor, I don't know, so I'll just assume whichever one read_dir() returns first will do.) In that case, use $acc_files[0] for your control file name, after changing the suffix:

($control_file = $acc_files[0]) =~ s/pdf$/txt/;

In reply to Re: FIle name help! by aaron_baugher
in thread FIle name help! by Anonymous Monk

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.