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?
Here is the code:
#! /bin/perl
#
# Create the files to delete list file
#
#
# Find all the files
#
print "Extracting files in directory";
@file_list = `dir c:/s`;
#
# Build the list of directories and files
#
$temp_index = 0;
$file_index = 0;
$directory_index = 0;
$dir_list_size = scalar(file_list);
while ($temp_index lt $dir_list_size)
{
chomp file_list(temp_index);
$parse_line = split($temp_index);
$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 = $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)
{
$file_read = 0;
#
# Is the file marked as one to be deleted
#
if (file_deleted[compare_index] == 0)
{
duplicate_index = file_index + 1;
while (duplicate_index < $number_of_files)
{
if (file_size[file_index] ==
file_size[duplicate_index])
{
#
# Read the file if we need to
#
if (file_read == 0)
{
#
# Mark the file as read to avoid reading it again
file_read = 1;
}
#
# Compare the file
#
if (main_file == possible_file)
{
#
# File is the same delete it
#
#
# Build the file name to delete
#
$delete_file_name == $directory[actual_file[duplicate_index].
$actual_file[duplicate_index];
#
# Remove the file
#
# system(delete $delete_file_name);
file_deleted[duplicate_index] =1;
}
}
}
}
}
$number_files = scalar(@full_file_list);
#
# Build the list of file names dates and size
#
$file_index = 0;
$check_file_index = 0;
while ($file_index < $number_files)
{
#
# Split the string into the various components into an array
#
if (1 == 1)
{
$check_file[$check_file_index] = $full_file_list[file_index];
$check_file_index = $check_file_index + 1;
}
$file_index = $file_index + 1;
}
$number_file_index = $file_index;
#
# Process the file list
#
$compare_file_index = 0;
while ($compare_file_index < $number_actual_files)
{
$compare_file_index = $compare_file_index + 1;
}
Thanks,
Andrew
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>