By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

Error while using File::Listing qw(parse_dir);

P: 36
HI every body,
i am always getting the following error while parsing a directory .

i am reading a directory by doing ls
and trying to find out the name,type,size, mtime and mode of files from the directory
Expand|Select|Wrap|Line Numbers
  1. my @valeu =@{$Files[0]};
  2. foreach my $file (parse_dir(\@valeu))
  3. {
  4.  @Files = $ftp->ls('-lR');
  5. my($name,$type,$size1,$mtime1,$mode1) = @$file;
  6. }
  7.  
Use of uninitialized value in length at C:/Perl/lib/File/Listing.pm line 248, <DATA> line 1.
Use of uninitialized value in substitution (s///) at C:/Perl/lib/File/Listing.pm line 47, <DATA> line 1.
Use of uninitialized value in pattern match (m//) at C:/Perl/lib/File/Listing.pm line 49, <DATA> line 1.
Use of uninitialized value in string eq at C:/Perl/lib/File/Listing.pm line 57, <DATA> line 1.
Use of uninitialized value in string eq at C:/Perl/lib/File/Listing.pm line 57, <DATA> line 1.

let me know if you need any info

thanking you in advance
Apr 17 '08 #1
Share this Question
Share on Google+
5 Replies


KevinADC
Expert 2.5K+
P: 4,059
if your script is not real long please post the whole script, the line numbers where the error messsages are coming from is what you need to look at.

Edit:

the errors are actually coming from the module you are using: File::Listing which is a module I am not familiar with. Are you sure your usage of the module is correct?
Apr 17 '08 #2

P: 36
if your script is not real long please post the whole script, the line numbers where the error messsages are coming from is what you need to look at.

Edit:

the errors are actually coming from the module you are using: File::Listing which is a module I am not familiar with. Are you sure your usage of the module is correct?
Hi kevin
Thanks for the reply, the funny thing is it is not throwing any error message and line no of my script, when i run it directley throwing the error from the module it self.
Expand|Select|Wrap|Line Numbers
  1.  my  $host = 192.74.36.180;
  2.     my  $path = '/Archive/';
  3.     my $path1 = 'D:/Builds/';
  4.  
  5.     my  $ftp = Net::FTP->new($host, Timeout => 1800) or die "Cannot contact $host: $!";
  6.  
  7.     $ftp->login(123', '123') or die "Cannot login ($host):" . $ftp->message;
  8.  
  9.     $ftp->cwd($path) or die "Cannot change directory ($host):" . $ftp->message;
  10.  
  11.     my  @Files = $ftp->ls('-lR');
  12.  
  13.     $ftp->binary();          
  14.  
  15. foreach my $file (parse_dir(\@Files)) 
  16.     {
  17.           my($name, $type, $size1, $mtime1, $mode1) = @$file;
  18.          # my ($sec,$min,$hour,$mday,$mon,$year,$wda) = localtime($mtime);
  19.             my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)= stat($name);
  20.             my ($sec,$min,$hour,$mday,$mon,$year,$wda) = localtime($ctime);
  21.             $year +=1900;
  22.             my @validfiles;
  23.             my @invalidfiles;
  24.         if($mon >= 3 && $mday >= 0 && $year >= 2008)
  25.         {
  26.             logMsg ("File $name Matched with criteria");
  27.             #my $path = "$sourceDirectory".$sourcfiles[$i];
  28.             push(@validfiles,$name);
  29.         }
  30.         else
  31.         {
  32.             push(@invalidfiles,$name);
  33.         }
  34.  
  35.  
  36.  
  37.  
  38.             if ($type eq 'f') 
  39.             {
  40.                   $ftp->hash($name,102400);
  41.                  # $ftp->cwd($path1) or die "Cannot change directory ($host):" . $ftp->message;
  42.                  chdir($path1);
  43.                  opendir(DST, "$path1") || die "Cannot open directory $destinationDirectory $!";
  44.                  @dstFiles= readdir(DST);
  45.                 closedir(DST);
  46.                 print $dstFiles[2];
  47.                 my @newFiles1 = split(/\//,$dstFiles[2]);
  48.                 if ((grep /^\Q$name\E/, @dstFiles ))
  49.                 {
  50.                     print "no need to download";                    
  51.                 }
  52.                 else
  53.                 {
  54.                     chdir($path1);
  55.                     $ftp->get($name) or warn "Could not get $_, skipped: $!";    
  56.                 }
  57.  
  58.  
  59.                 # my($name1, $type1, $size1, $mtime1, $mode1) = @$file;
  60.  
  61.                  #$ftp->cwd($path1) or die "Cannot change directory ($host):" . $ftp->message;
  62.  
  63.                   #$ftp->get($name) or warn "Could not get $_, skipped: $!";
  64.                   #$ftp->put($name, '/Builds/') or warn "Could not get $_, skipped: $!";
  65.                   #EXTRACT("C:/temp/$name");
  66.             }
  67.       }
  68.  
  69. $ftp->quit or die "Could not close the connection";
  70.  
any way i am sending the script you can have a look and let me know if anything come across to you..

thanking you in advance
Apr 17 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
Don't send me your script. I will not take a look at it.
Apr 17 '08 #4

KevinADC
Expert 2.5K+
P: 4,059
Maybe you missed my edit:

the errors are actually coming from the module you are using: File::Listing which is a module I am not familiar with. Are you sure your usage of the module is correct?
Apr 17 '08 #5

numberwhun
Expert Mod 2.5K+
P: 3,503
Ok, just a couple of things.

First, maybe its just the fact that I only got out of bed a couple of minutes ago, but I don't even see in this code WHERE you have a "use File::Listing qw(parse_dir);" line. You would have to have that in there if it is to use the module.

Second, I personally LOVE syntax highlighting. It can end up helping you troubleshoot and you don't even realize it. In the line below, I believe you are missing a single quote. Having 3 of them, is not very kosher.

$ftp->login(123', '123') or die "Cannot login ($host):" . $ftp->message;


Regards,

Jeff
Apr 17 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.