Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
If I'm following your spec, the easiest way to accomplish your goal is use a hash:
#!/usr/bin/perl -w use strict; use File::Find::Rule; use File::Basename; my @filelist = qw(1234567_3a_20101000.html 99877_b_20111111.html 9987 +7_c_20111111.html 99877_d_20111111.html 99877_e_20111111.html 99877_u +f_20111111.html 1234567_g_20101000.html 99877_h_20111111.html 99877 +_i_20111111.html 99877_j_20111111.html 99877_k_20111111.html 99877_ll +_20111111.html 1234567_pl_20101000.html 99877_qa_20111111.html 998 +77_rr_20111111.html 99877_sx_20111111.html 99877_xy_20111111.html 998 +77_nm_20111111.html); my %want; $want{$_}++ for @filelist; my $dir = '/var/www/files/'; my $find = File::Find::Rule ->file ->name(qr/\.html?$/) ->start( $dir ); my $f_count = 0; my @found_html; while ( defined ( my $html_document = $find->match ) ) { $f_count++; my $filenames = basename( $html_document ); push @found_html, $filenames if $want{$filenames}; }

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

In reply to Re: Search array of file names in directory structure by kennethk
in thread Search array of file names in directory structure by Anonymous Monk

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (3)
    As of 2018-03-19 01:31 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (231 votes). Check out past polls.