To be honest, I don't think your main slowdown isn't in the splitting up of the data, but in the system call. After all, split and a regex do their job in a matter of microseconds.

As you're only interested in the properties of one file, stat does indeed look like the more appropriate approach, especially since you seem to care about micro-optimizations in speed so much. It'll return you the user and group IDs as an integer, so look at getpwuid and getgrgid in scalar context, if you want the names.

And finally, as still one more an alternative to your solution while using `ls`, you could use unpack, since `ls` produces fixed with columns. This seems to work for me:

my ($p, $l, $o, $g, $s) = unpack "A10xA4xA8xA8xA8", `ls -l "$fnm"`;
It will strip trailing spaces for the names, but it will not strip leading spaces, for the numbers. I don't know of a template that does strip leading spaces (see perldoc -f pack for the available templates), but it doesn't prevent you using these strings as a number anyway, so I wouldn't worry about them.

In reply to Re: Which witch is the quicker witch? by bart
in thread Which witch is the quicker witch? by Dismas

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.