in reply to Re: Please advice
in thread Please advice

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 }

Replies are listed 'Best First'.
Re^3: Please advice
by runrig (Abbot) on Aug 10, 2011 at 15:14 UTC
    @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'.
Re^3: Please advice
by duelafn (Parson) on Aug 10, 2011 at 14:34 UTC

    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

Re^3: Please advice
by cdarke (Prior) on Aug 10, 2011 at 19:41 UTC
    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

        I'd suggest File::Find for the directory reading, and check out the -X file operators in perldoc perlop.

        We're not trying to be obstructive, just to give you a little push to get past your insecurity about this. You're heading the right direction - just keep going!