my @emptyfiles = grep { /^\d+$/ } grep { -f } glob '*';

Let's look at this right to left. glob '*' returns a list of files, the same list you'd get if you use * as the argument to an ls or dir command, except it's just the file names, not the dates, sizes, etc that those commands also return. This list will be the input to the grep command.

my @emptyfiles = grep { /^\d+$/ } grep { -f } [ 1 temp.dat testdirecto +ry 10 resume.wd ]

grep { something } list returns the list that results by applying the something as a test. If it passes, it is included in the return. glob will return both file and directory names in its list. Applying the -f test will remove the directories. The middle grep returns a list also.

my @emptyfiles = grep { /^\d+$/ } [1 temp.dat 10 resume.wd ]

we can use another grep to further filter the list to just the files we want, those whose name consists of 1 or more digits, and nothing else.

my @emptyfiles = [1 10]
But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)


In reply to Re^3: create array of empty files and then match filenames by GotToBTru
in thread create array of empty files and then match filenames by angela2

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.