AndrewMcHorney wrote:
> Hello

Hello,

> I do not have my perl books with me and so I cannot diagnose the error I
> am getting with several if statements. Could someone assist?

Do you have the Perl documentation installed on your hard drive?

perldoc perldiag


> Here is the code:
> 
> #! /bin/perl

You can let perl help you find problems by including these two lines:

use strict;
use warnings;

And if you want more verbose warning messages you could include this:

use diagnostics;


> #
> # Create the files to delete list file
> #
> 
> #
> # Find all the files
> #
> print "Extracting files in directory";
> 
> @file_list = `dir c:/s`;

You should use a module like File::Find to get a list of all your files.

perldoc File::Find


> #
> # Build the list of directories and files
> #
> 
> $temp_index = 0;
> 
> $file_index = 0;
> 
> $directory_index = 0;
> 
> $dir_list_size = scalar(file_list);

file_list is a bareword, you probably meant to use the array @file_list.


> while ($temp_index lt $dir_list_size)

'lt' is used for comparing strings, you should use '<' to compare numbers.


> {
> 
>    chomp file_list(temp_index);

Do you have an lvalue subroutine called file_list defined somewhere?
temp_index is a bareword, you probably want to use a variable there.


>    $parse_line = split($temp_index);

That is short for:

    $parse_line = @_ = split( /$temp_index/, $_, 0 );

Since $_ is probably empty and you are not using the contents of @_ anywhere
it is hard to figure out what you are trying to do here.


>    $file_read = 0;
> 
>    #
>    # Determine if this is a directory and if so add it to the
>    # directory array and increment the index
>    #
>    if ($parse_line[0] == "Directory")
>    {
>       $directory_list = $parse_line[1];
>       $directory_index =$directory_index + 1;
> 
> 
>    }
>    else
>    {
>       $actual_files[file_index] = $parse_line[0];
>       $file_size[file_index] = $parse_line[5];
>       $file_deleted[file_index] = 0;

file_index is a bareword, you probably meant to use the variable $file_index.


>       $file_index = $file_index + 1;
> 
>    }
> 
>    $temp_index = $temp_index + 1;
> }
> 
> $number_files = scalar(@actual_files);
> 
> #
> # Loop through the list of files
> #
> $file_index = 0;
> while ($file_index < $number_of_files)
> 
> 
[ snip more bareword littered code ]
> 
> 
> #
> # Process the file list
> #
> 
> $compare_file_index = 0;
> 
> while ($compare_file_index < $number_actual_files)
> {
>     $compare_file_index = $compare_file_index + 1;
> }

Why the loop?  Why not just:

my $compare_file_index = $number_actual_files;




John
-- 
use Perl;
program
fulfillment

-- 
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