gnu@perl has asked for the wisdom of the Perl Monks concerning the following question:

I have a program that gets its info from a config file, that config file names other files within it. I would like to be able to use file name globbing in the config file. This will allow me to put one entry into the file instead of >100.

The problem I have is when I am parsing the config file. I am checking each entry to see if it is valid or not before acting on it. Here is a psuedo code example:

$fileGlob = /var/adm/messages.*; for (< $fileGlob >){ do some things to check each file.... }

This works fine, the problem comes in when there is a typo or a non-existant file is entered in the config file. If the glob does not evaluate to an existing file/s on the system the code block does not execute.

Any ideas would be appreciated.

TIA, Chad.

Replies are listed 'Best First'.
Re: testing a file glob
by Aristotle (Chancellor) on Sep 23, 2002 at 22:01 UTC
    $fileGlob = '/var/adm/messages.*'; my @file = glob $fileGlob; if(not @file) { # glob was wrong or there were no files } for (@file){ # do some things to check each file }

    Makeshifts last the longest.