Ok, I searched for a previous post on this site that would answer my question and I was unable to find it. So here it goes. I want to be able to scan a directory and store all the files in an array. I have been succesful with this so far. From there I want to be able to create a list where the user can delete one of more of those files. This is what I have so far
#### # Get File List #### sub get_file_list { my $dfiles = "/Library/WebServer/Documents/userpages/uploads"; opendir(DIR,$dfiles); my @files = grep { $_ ne '.' && $_ ne '..' } readdir(DIR); closedir(DIR); print<<HTML; <html> <head> <meta http-equiv="content-type" content="text/html;charset=ISO +-8859-1"> <title>Upload - Delete Files</title> </head> <body bgcolor="#ffffff"> <form action="upload.cgi" Method="post" ENCTYPE="multipart/form-da +ta"> <P>List of Files: <br> HTML foreach (@files) { print "<br> Delete this File: <INPUT TYPE=\"submit\" NAME=\"action\" V +ALUE=\"$_\">\n"; } print<<HTML; <br> <br> <INPUT TYPE="submit" NAME="action" VALUE="Submit"> <INPUT TYPE="submit" NAME="action" VALUE="Delete"> </FORM> HTML }
The print statement in the foreach loop doesn't make a whole lot of sense but it was the only thing I could come up with to pass the value of the filename. I know I will need to use unlink to remove the files but as you can see I'm not there yet. Any suggestions are appreciated.

Edit: chipmunk 2001-11-18


In reply to Allow User to Select Which Files to Delete by lex2001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.