The module stats is a built-in function of Perl as Ratazong points out; so you don't need File::stats and as Ratagong also points out, using File::stats causes the built-in stats to be overridden which is probably not what you'd want overall...but that's just MHO.

The stats() function returns an array reference, not the array itself. So you'll have to derefference the result of stat() before you then try to access element 9. That is what I believe ikegami was showing you.

Also, in your included code snippet you left out the brackets around 9...but I presume that was just an oversight in what you posted, not as it occured in your code.

UPDATE: I inadvertantly posted that the fuction is stats(). It should be stat() I believe. Sorry.

UPDATE 2: Well, now I'm confused. When I was trying the case that the OP posted, I found that stat() returned an array reference (hence, my posted response). But when I was playing around with it a little further, I find that, indeed, I can use the construc my $mtime = (stat($i))[9] to get the last modified time. And I can't get it to return the array reference now. So now I'm a bit confused as this implies that the OP's only mistake, as far as I can tell, was that there were no enclosing square brackets around his array element number. Once I corrected that, the OP's code works for me.

ack Albuquerque, NM

In reply to Re: not able to get last modified time of a file by ack
in thread not able to get last modified time of a file by srinikar

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.