pankaj_it09 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Searching a file and then opening it
by planetscape (Chancellor) on Nov 07, 2006 at 06:43 UTC

    Super Search is your friend. The docs for File::Find, File::Find::Rule, and open should get you started. If you are still having problems with your code after you read those, post back with the snippet that's giving you trouble.

    HTH,

    planetscape
Re: Searching a file and then opening it
by prasadbabu (Prior) on Nov 07, 2006 at 06:46 UTC

    You have to take a look at stat, opendir, open and File::Find::Rule. By using those mentioned functions and module, you can achieve your target. As planetscape++ said, you have to try to write the code and post the code if you have any problem. Below is a sample code.

    use strict; use warnings; use File::Find::Rule; my ($filename, $giventime, $directoryname); my @files = File::Find::Rule->file() ->name( "$filename" ) ->ctime ("< $giventime") ->in( "$directoryname" ); for my $file (@files) { open ($fh, '<', $file) or die ("$!"); }

    update: Added code

    Prasad

Re: Searching a file and then opening it
by smokemachine (Hermit) on Nov 07, 2006 at 17:09 UTC
    perl -e '$name = shift || die "name?!"; $dir = shift || "."; $time = s +hift || 1; while(<$dir/* >){open FILE, $_ if scalar localtime((stat)[10]) < $time && /$name/}' +test . 123
Re: Searching a file and then opening it
by chrism01 (Friar) on Nov 08, 2006 at 05:29 UTC
    FYI, the ctime is not creation time. In std Unix there is no way to find a file's creation time.
    ctime = inode change time.

    Cheers
    Chris