Results 1 to 2 of 2

Thread: Reading files and folders in a directory

  1. #1
    Registered
    Join Date
    Aug 2009
    Location
    texas
    Posts
    26
    Rep Power
    0

    Reading files and folders in a directory

    I want to show the files and folders in a directory. I am using a perl script and @files = <../directory/*> command. Is there a command that will do something similar that will accept a string variable that contains the directory to be interrogated?

    Thanks

  2. #2
    Rick
    Join Date
    May 2002
    Location
    Minneapolis, MN
    Posts
    1,753
    Rep Power
    19
    Perl largely relies on UNIX command equivilents for accessing files and directories. You can read a directory into an array using something like:
    Code:
      opendir (THISDIR,"$path_to_dir") || die "$htmlhead $! Can't Open Directory $path_to_dir";
       @temp = readdir(THISDIR);
      closedir (THISDIR);
    My Perl is getting pretty rusty these days, but I'm sure if you do some searches for Perl tutorials that you can find more elaborate examples. Good luck!
    Rick Trethewey

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •