in reply to Array problem......PLEASE HELP!
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:
@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.my $files = join(" ", (glob("0[89]-*.txt")));#I suffer from parentheti +caphilia. sorry
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array problem......PLEASE HELP!
by green_lakers (Novice) on Jan 05, 2009 at 22:15 UTC | |
by zentara (Cardinal) on Jan 05, 2009 at 22:35 UTC |