Bignut_Squirrel has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
My script needs to read all the files in a directory into an array for comparison. This works when I directly provide the path to the directory as below:
@filearray = </var/log/*>;
I want to make the code more flexible so I need to store the directory in a variable instead, but this way does not seem to work:
$path = '/var/log/*'; @filearray = <$path>;
This results in an empty array. I have tried different quotations, but I can't figure out the syntax. Is there a way to do this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading a directory into an array using <>
by toolic (Bishop) on Jun 16, 2011 at 19:55 UTC | |
|
Re: Reading a directory into an array using <>
by Marshall (Canon) on Jun 16, 2011 at 19:45 UTC | |
|
Re: Reading a directory into an array using <>
by 7stud (Deacon) on Jun 16, 2011 at 20:30 UTC |