Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I'm having trouble filtering out filenames when the "file path" is present.

Objective is to filter out files that doesnt match ULOG.whateverextension
Possible names for $_ are:
C:\\Ba\\Log\IncorrectULOG.20010101 (unwanted)
C:\\Ba\\Log\ULOGIncorrect.20010809 (unwanted)
C:\\Ba\\Log\ULOG.20011010
C:\\Ba\\Log\ULOG.20012510
The last 2 files is the one I want.
Using my Code Base: if (-f $_ && $_=~ /ULOG\./i)
The results show :
C:\\Ba\\Log\IncorrectULOG.20010101 (Unwanted)
C:\\Ba\\Log\ULOG.20011010
C:\\Ba\\Log\ULOG.20012510
Can someone please help me out with a pattern to filter the unwanted filename?
Thanks
Regards
Steven Chua

Replies are listed 'Best First'.
Re: Pathname\Filename Filtering
by Zaxo (Archbishop) on Sep 28, 2001 at 08:27 UTC
    my $path = "C:\\\\Ba\\Log\\"; # or whatever this win32 stuff will take my @goodnames = grep {$_ !~ m/Incorrect/} glob($path*ULOG*);
    The glob function takes care of existance and gives an initial filter. It might be able to do the whole job, but I'm not familiar with its quirks on your platform.

    After Compline,
    Zaxo

Re: Pathname\Filename Filtering
by Anonymous Monk on Sep 28, 2001 at 08:33 UTC

    I'm answering my own question after some feedback from other perl communities
    if (-f $_ && $_=~/\\ULOG\./i)
    Basically searches for the pattern "\ULOG."
    Regards
    Steven Chua