Gerard has asked for the wisdom of the Perl Monks concerning the following question:
Hello All,
I very new to all this so please bear with me. (This is also my first post). I am trying to add files from a directory to an array, which I learnt last night from reading on this site that I could do by
@allcontacts = <*.cd>;
That was fantastic and I also learnt that I could use something like
@allcontacts = <a_directory/*.cd>;
However I now want to use a variable to in place of the a_directory/*.cd
I tried doing this with the following code...
But received the message unable to open the file. As it worked fine before I put the variable in I know it has something to do with this. I have tried escaping the characters but I am obviously doing something wrong. I am sure there is a simple answer, but I have looked for ages, and just feel really stupid. I would greatly appreciate it if some wise monk would impart some of their wisdom to me. Cheers, Gerard.#set the initial values for the text boxes to the first contact's det +ails #cd32/ is the directory $searchcontacts = "cd32/*.cd"; @allcontacts = <$searchcontacts>; $count = "0"; #display the first files contents first open(DAT, $allcontacts[$count]) || die("Could not open file!"); @allcontactdetails=<DAT>; close(DAT);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Adding Files in a directory to an array
by davorg (Chancellor) on Oct 09, 2001 at 13:21 UTC | |
by jeroenes (Priest) on Oct 09, 2001 at 15:10 UTC | |
Re: Adding Files in a directory to an array
by Caillte (Friar) on Oct 09, 2001 at 13:18 UTC | |
Re: Adding Files in a directory to an array
by busunsl (Vicar) on Oct 09, 2001 at 13:25 UTC | |
by Gerard (Pilgrim) on Oct 09, 2001 at 15:29 UTC |
Back to
Seekers of Perl Wisdom