it need to *not* match "." or ".." entries

How about getting rid of these just like you do with the other useless lines:

... foreach(@_) { # skip if it doesn't start with either a space or backslash next if (!/^[ \\]/); # skip if it's just "." or ".." next if (/^\s*\.{1,2}\s/); if (/^\\/) { $path = "$_\\" } elsif (/^\s*(.*\S)\s{5,}([HDRSA]+)\s*(\d+)\s*(.*)/) { my ($file,$att,$size,$date) = ($1,$2,$3,$4); my $ext = ( $file =~ /\.([^.]+)$/ ) ? $1 : "DIR"; print ...; } }

That last bit about setting $ext follows your assumption that if there's no dot in the name, it must be a directory (but I think this is not a reliable assumption). Note that file names may contain multiple periods, and I think you want $ext to hold just the characters after the last one (in your original version, a file name like "rel_3.1.tar.gz" would set $ext to "1.tar.gz").

Your expression for getting/setting $path was also a bit odd. The perlre man page says:

Also remember that "|" is interpreted as a literal within square brackets, so if you write "[fee|fie|foe]" you're really only matching "[feio|]".
And of course, directory names might include dash, period or other punctuation that wouldn't match \w. Your code made it seem like lines with initial slash would contain only a path name and nothing else, so I simplified on that basis (but I don't know if this assumption is correct).

In reply to Re: Happy fun regexping by graff
in thread Help needed with reducing function to a single regex by cyberconte

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.