As an example of what 1nickt suggested, maybe something like:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -e "my @files = qw( TUMI-1354839054_alt1 1.psd maur-1111.psd Sam-I-Am.gif maur-1110.psd ); ;; my %user_tag_title = qw(TUMI TUMI BW BW maur maurices); ;; my ($rx_user_search) = map qr{ $_ }xms, join ' | ', map quotemeta, reverse sort keys %user_tag_title ; print $rx_user_search, qq{\n}; ;; my %files_seen; FILE: for my $file (@files) { next FILE unless my ($user) = $file =~ m{ ($rx_user_search) }xms; push @{ $files_seen{$user} }, $file; } dd \%files_seen ;; USER: for my $user (sort keys %user_tag_title) { next USER unless exists $files_seen{$user}; ;; printf qq{%d $user_tag_title{$user} files \n%s \n\n}, scalar(@{ $files_seen{$user} }), join qq{\n}, @{ $files_seen{$user} }; } " (?msx-i: maur | TUMI | BW ) { TUMI => ["TUMI-1354839054_alt1"], maur => ["maur-1111.psd", "maur-1110.psd"], } 1 TUMI files TUMI-1354839054_alt1 2 maurices files maur-1111.psd maur-1110.psd
For a discussion of how  $rx_user_search is built, see haukex's Building Regex Alternations Dynamically.


Give a man a fish:  <%-{-{-{-<


In reply to Re: count multiple variables in a single array. by AnomalousMonk
in thread count multiple variables in a single array. by flieckster

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.