in reply to Please advice

You can get the arguments passed into your script via $ARGV[#] (e.g. $first = $ARGV[0];). Then use opendir() and readdir() to find all the files in each of the subdirectories. After that, it's just loops and print statements.

Replies are listed 'Best First'.
Re^2: Please advice
by ashish_sun123 (Initiate) on Aug 10, 2011 at 14:17 UTC

    I have written this much of code as of now.

    #!/usr/bin/perl use strict; use warnings; use POSIX (); print ("Enter the directory name and date as input arguments:"); chomp($which_directory=@ARGV[0]); chomp($which_date=@ARGV[1]); die("Nothing entered as directory path name\n" if ($which_directory eq + ""); die("Nothing enetered as update date\n" if ($which_date eq ""); opendir(DIR,$which_directory); my @dir = grep { !/^\.+$/ } readdir(DIR); foreach (@dir) { -->Here I need to get all sub directories and then do a cd in each + diectory }
      @ARGV is the array of command line arguments (see perlvar .. and they would not normally need to be chomped). If you want to prompt the user for arguments, you can use:
      print "Enter directory: "; chomp(my $dir = <STDIN>);
      Or you might try IO::Prompt. For searching subdirectories, you can use File::Find. You are automatically chdir'd to the directory of each file as it is 'found'.

      To do this manually, you will need a recursive subroutine. Instead, I would recommend using File::Find to iterate over your files.

      Good Day,
          Dean

      No need to chomp @ARGV, these are command-line arguments, they are not read from a file.
      To find if a file is a directory, you can use -d
      To find the date/time stamps on a file, use stat

        Monks, I need help for finding the sub directories under a directory and then reading the time stamp of all files and then matching the timestamp of files with the passed input date. Surely I need help here