in reply to Re^2: Find most recently file
in thread Find most recently file

Please read Writeup Formatting Tips - in particular, surrounding your code with <code> tags will make it dramatically more legible. In the future, you should also include your output and a better description of your problem - saying "but it does not work" is usually frowned upon since there are many ways a code can "not work".

In your code, note that the line $recent = (stat(_))[9]; is missing a sigil in front of $_ - you mean $recent = (stat($_))[9];. The big problem you are encountering is likely that you are not testing your file name in your plus_recent subroutine to see if the file is a log file - you are locating the most recent file in your entire directory tree (after the $_ fix).

Note also in your commented open line you should likely use or in place of || - see Operator Precedence and Associativity.

Update: Learned something new re: stat. Thanks Bloodnok.

Replies are listed 'Best First'.
Re^4: Find most recently file
by Bloodnok (Vicar) on Mar 31, 2009 at 17:23 UTC
    The sigil isn't missing in the context of the given code snippet - ...If stat is passed the special filehandle consisting of an underline, no stat is done, but the current contents of the stat structure from the last stat, lstat, or filetest are returned. ... - from stat

    A user level that continues to overstate my experience :-))