in reply to Regex for zip files.

Ok here is the issue. That one code posted doesn't match anything. My array contains zip files and zip.meta files. With my orignal code it matches the zip on the first pass, then on the 2nd it matches zip and zip.meta. I would like it to match zip if it's just a zip at the end, or just match zip.meta if that's found within the array.

Replies are listed 'Best First'.
Re^2: Regex for zip files.
by Marshall (Canon) on Jun 09, 2009 at 21:31 UTC
    As a suggestion, try this:
    my @zips = grep { /\.zip$/} @uploads; my @meta = grep {/zip\.meta$/} @uploads; # "Your Mother" pointed out that I had meta/$ instead # of the correction shown. .meta$/} Oooops. print "zips= @zips\n"; print "zipmeta= @meta\n";
    Update: Something like this might work.
    foreach my $upload (@uploads) { if ($upload =~ m/zip$/i) { print "I GOT A ZIP\n"; } elsif ($upload =~ m/zip\.meta$/i) { print "I GOT A META\n" } else { print "I got NADA" } }
Re^2: Regex for zip files.
by Popcorn Dave (Abbot) on Jun 10, 2009 at 01:11 UTC
    If that's the case, you need to provide a sample of your data and show what's not working.


    To disagree, one doesn't have to be disagreeable - Barry Goldwater