Hi, I understand that what you wrote is marked as "pseudocode", but I noticed a couple of strange things:
$files{3} = $input_directory,"3";
Maybe you meant to put a dot "." instead of a comma ","?

Another thing that I don't understand from this fragment is if %files holds filenames or directory names. The use of open() and close() seems to point to "filenames", but in this case the readdir(DATA) should be simply <DATA>.

Regarding the open(), at the price of backward compatibility with 5.6, I use lexical filehandles instead of barewords:

open my $data, ...
Moreover, I usually stick to the three argument version of open(), not because this is requested by this particular application (I actually don't know), but more for sake of a mental habit (yes, I'm mental :) :
open my $data, '<', $files{$_} ...
I find it better not only because it avoids nasty problems when the filename comes from the "untrusted external" (which could lead to embarassing security holes), but also because it visually marks that this open is for read instead of write.

Last, even if the plain die does the work (especially in pseudocode!), it could be helpful to provide a more sensible feedback message, either directly:

open my $data, '<', $files{$_} or die "open('$files{$_}'): $!";
or with
use Fatal qw( open );
in the script's preamble.

Forgive me for jumping on your shoulders this way, but the OP seems to have some bias towards blind cut-and-paste, you know, so it could be useful for her|him to think about these issues ;)

Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Don't fool yourself.

In reply to Re^2: Working with a unkown number of arrays by polettix
in thread Working with a unkown number of arrays by Win

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.