Why must you use the array @files? This strikes me as a rather pointless constraint. What are you trying to do?

Dealing with your attempt to read the files in your directory: as said by moritz, use glob. It's what it's made for. Your first step would look something like this:

my $files = join(" ", (glob("0[89]-*.txt")));#I suffer from parentheti +caphilia. sorry
@files will now contain a blank-separated list of files which start with 08 or 09, followed by a hyphen and ending with '.txt'. You could then pass this to your ls -l command (the one in the backticks) and do the post-processing from your hash.pl routine.

Alternatively, you could use opendir, readdir, and grep, resulting in something like this:

opendir(my $DH, "."); # opens pwd @files = grep {/^0[89]-.+\.txt$} readdir($DH); closedir($DH);

But it would be a really good idea to tell the Monks–many of whom actually like explaining the nuances of Perl if the question is couched appropriately–what your goal is.


Information about American English usage here and here. Floating point issues? Please read this before posting. — emc


In reply to Re: Array problem......PLEASE HELP! by swampyankee
in thread Array problem......PLEASE HELP! by green_lakers

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.