Hello Perl-Monks and Happy New Year!

Here's what I have going on...An administrator can add/upload any number of product images to a particular product category directory but can only utilize 10 of those images for display with the product. There aren't many products so I'm using a flat-file db. When the product images are uploaded they are renamed to contain the product id number. This all works great except when the product is removed from the database...the only product images removed are the ones actually being utilized for display. Here's a quick snip of the code that shows the removal of the photo-1/thumb-1 (this is the same for display images 2-10):
if ($photo1 ne "") { {system("rm $photodir/$category_id_number/$photo1");} my @resize1 = split(/\./, $photo1); my $photo1t = $resize1[0] . "-T." . $resize1[1]; {system("rm $photodir/$category_id_number/$photo1t");} }
Is there a way to look through a directory to see if any image files contain the id number and simply remove all images that contain the id number?

Thank you!

In reply to Removing Multiple Image Files by lisaw

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.