in reply to Re^8: Display filenames in mbox folder
in thread Display filenames in mbox folder

say requires that you put use feature 'say'; or use 5.010; (or any version greater than that) at the top of your script. Commenting out use warnings; use strict; is not a solution.

use warnings; use strict; my $PATH = '/tmp/foo'; opendir my $dh, $PATH or die $!; print "\"$_\"\n" for grep { -f "$PATH/$_" && /^([0-9][\w.:,=\-]+)$/ } readdir $dh; closedir $dh; __END__ "1231125716.6864.bLyyk:2,S" "123test" "1422830161.R3.asus64:2,S"

If you have further trouble, please see Basic debugging checklist and How do I post a question effectively?

Replies are listed 'Best First'.
Re^10: Display filenames in mbox folder
by peterr (Scribe) on Mar 02, 2015 at 03:55 UTC

    After testing the above script, and had no output for a KMail folder, I realised it is not recursive. There are sub-folders like ..

    /cur

    /new

    /tmp

    That is why it hasn't been working for me. :D

    Once I specified the exact path, the pattern worked fine, and I was able to push out all the filenames. It totalled 591 which is what I expected. Then wrote a script to compare that output with another "ls". The "culprit" file turned out to be one with a filename of "1232706568.2627.1XNmk~:2,S". It was from 2008; possibly KMail had a hiccup back then and wrote a filename with a "tilde" in it. Will rename the file and get rid of the tilde in the filename (and any others).

    The issue with recursion was also true for the sub readMessageFilenames, in that it doesn't do a recursive search. Once I set it to the exact pathname, the pattern worked fine. Although that means I have to run it for every sub folder. I did try adding "-r" to grep { -f "$PATH/$_" && /^([0-9][\w.:,=\-]+)$/ } but got an error. Thanks for all your help. :)

      I realised it is not recursive
      Use File::Find and friends for recursive directory traversal.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ