The File::Find::name didn't seem to make any difference.  I still have
to be in the directory that I want to search. Hmmm.

-----Original Message-----
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED] 
Sent: Friday, March 11, 2005 3:13 PM
To: Bret Goodfellow; beginners@perl.org
Subject: RE: Why am I getting data from Current Directory?


Bret Goodfellow wrote:
> I am writing a script to list out a directory's contents, showing the 
> number of days since modified.  The problem I am having is that the 
> script doesn't list out the "modified time" unless I change to the 
> directory being listed.  If I change to the directory I want to list, 
> then all works okay.  Is there a way to fix this script so that I 
> don't have to run the script from the current directory?
> 
> use strict;
> use warnings;
> use File::find;
> use File::stat;
> 
> my $arg_length;
> my $arg_lastchar;
> my $arg_string;
> my $Len;
> 
> $arg_length = length($ARGV[0]);
> $arg_lastchar = substr($ARGV[0], $arg_length-1, 1); $arg_string = 
> $ARGV[0];
> 
> print "Argument: $arg_string\n";
> print "length: $arg_length\n";
> print "last character: $arg_lastchar\n";
> 
> print "Contents of $arg_string\n";
> opendir DH, $arg_string or die "Couldn't open directory: $arg_string 
> $!";
> 
> ######################################################################
> ##
> #
> # Read one file at a time into $_
> #
>
########################################################################
> #
> while ($_ = readdir(DH)) {
>  next if $_ eq "." or $_ eq "..";
>  next if -d $_ ;
> #####################################
> # append upto 30 blanks after the file name #
> #####################################
>  print $_, " " x (30-length($_));
>  print " age of file: ";  # age of file
> 
>  $Len = index(-M $_, ".");
        Change the $_ to $File::Find::name ( Fully qualified name of
file ) Is in the doc. Wags ;)
> 
>  print substr(-M $_, 1, $Len-1);
>  print "\n";
> }



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to