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

Strange. It works for me:
say for map { /^([0-9][\w.:,=\-]+)$/ } qw( 1231125716.6864.bLyyk:2,S 1 +422830161.R3.asus64:2,S);

Output:

1231125716.6864.bLyyk:2,S 1422830161.R3.asus64:2,S
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^8: Display filenames in mbox folder
by peterr (Scribe) on Mar 01, 2015 at 22:56 UTC

    I used the following ..

    #!/usr/bin/perl use warnings; use strict; say for map { /^([0-9][\w.:,=\-]+)$/ } qw( 1231125716.6864.bLyyk:2,S 1 +422830161.R3.asus64:2,S);

    and got:

    Possible attempt to separate words with commas at dirrecurs17.pl line +11. Bareword "say" not allowed while "strict subs" in use at dirrecurs17.p +l line 11. Execution of dirrecurs17.pl aborted due to compilation errors.

    So I commented out the ..

    #use warnings; #use strict;

    ran the script and got no output ??

    Possibly there is something wrong with my Perl install. I noticed various folders under /usr, like Perl, Perl5

      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?

        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. :)