i want to delete some files in a directory, not all files. i have code so far that lists the files with checkboxes so i can select the ones i want to delete. but i don't know what to do next.
my (@files, $file, $output, $found, $flag);
$page_title = "List CSV Files";
&html_page_top;
$submit_button = "Delete Files";
$reset_button = "Reset Form";
opendir (CSVDIR, "$db_csv_path") || &cgierr("unable to open directory in csv_list: $db_csv_path. Reason: $!");
@files = readdir(CSVDIR); # Read in list of files in directory..
closedir (CSVDIR);
FILE: foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
$output = gmtime((stat("$db_csv_path/$file"))[9]+3600*$time_offset);
my (@fixdate) = split' ',$output;
$output = $fixdate[0] . ' ' . $fixdate[1] . ' ' . $fixdate[2] . ', ' . $fixdate[4];
$found = 1;
if (!$flag) {
$flag = 1;
print qq|
<form action="$db_script_url" METHOD="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<table><tr><th>Delete</th><th></th><th></th></tr>|;
}
print qq|<tr><td valign="top"><INPUT TYPE=CHECKBOX NAME="$file" VALUE="delete"> |;
print qq|<td valign="top"><a href="$db_csv_url/$file" target="_export" name="Export" title="Open file">$file</a><td valign="top"> $output</td></tr>|;
}
if (!$found) { print qq|<p>no files found</p>|; }
if ($flag) {
print qq|</table>|;
print qq|
<p>Check which records you wish to delete and then press "Delete Files"</p>
<center><INPUT TYPE="SUBMIT" name="csv_cleanup" VALUE="$submit_button">
<INPUT TYPE="RESET" VALUE="$reset_button"></center>
</form>
|;
}
&html_admin_footer;
&html_page_bottom;
}
right now the csv_cleanup routine deletes all files in the directory. i don't know how to pass the files i want to delete to the routine. thanks!
Code:
sub list_csv_files { my (@files, $file, $output, $found, $flag);
$page_title = "List CSV Files";
&html_page_top;
$submit_button = "Delete Files";
$reset_button = "Reset Form";
opendir (CSVDIR, "$db_csv_path") || &cgierr("unable to open directory in csv_list: $db_csv_path. Reason: $!");
@files = readdir(CSVDIR); # Read in list of files in directory..
closedir (CSVDIR);
FILE: foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
$output = gmtime((stat("$db_csv_path/$file"))[9]+3600*$time_offset);
my (@fixdate) = split' ',$output;
$output = $fixdate[0] . ' ' . $fixdate[1] . ' ' . $fixdate[2] . ', ' . $fixdate[4];
$found = 1;
if (!$flag) {
$flag = 1;
print qq|
<form action="$db_script_url" METHOD="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<table><tr><th>Delete</th><th></th><th></th></tr>|;
}
print qq|<tr><td valign="top"><INPUT TYPE=CHECKBOX NAME="$file" VALUE="delete"> |;
print qq|<td valign="top"><a href="$db_csv_url/$file" target="_export" name="Export" title="Open file">$file</a><td valign="top"> $output</td></tr>|;
}
if (!$found) { print qq|<p>no files found</p>|; }
if ($flag) {
print qq|</table>|;
print qq|
<p>Check which records you wish to delete and then press "Delete Files"</p>
<center><INPUT TYPE="SUBMIT" name="csv_cleanup" VALUE="$submit_button">
<INPUT TYPE="RESET" VALUE="$reset_button"></center>
</form>
|;
}
&html_admin_footer;
&html_page_bottom;
}
right now the csv_cleanup routine deletes all files in the directory. i don't know how to pass the files i want to delete to the routine. thanks!