http://qs321.pair.com?node_id=711991


in reply to Log parsing question

This pertains to the second item you bring up. I'm not 100% sure why you need to 'do it all in one go' as you say, so this may or may not be helpful. But, adapted from a node by an anonymous monk posted here, you can generate a list of directories within a specified directory.

You can use this to make your script adapt in case the number of or name of directories varies from run to run.

This:
#!/usr/bin/perl -w use Data::Dumper; while(<*>){ push(@files,$_) if(-d "$_"); } print "\n". Dumper(@files) ."\n";
will produce output like this:
sean@seanc:~/code/temp$ ls -l total 16 drwxr-xr-x 2 sean sean 4096 2008-09-17 09:12 dir1 drwxr-xr-x 2 sean sean 4096 2008-09-17 09:12 dir2 drwxr-xr-x 2 sean sean 4096 2008-09-17 09:12 dir3 -rwxr-xr-x 1 sean sean 155 2008-09-17 09:11 dir_list.pl -rw-r--r-- 1 sean sean 0 2008-09-17 09:12 file1 -rw-r--r-- 1 sean sean 0 2008-09-17 09:12 file2 -rw-r--r-- 1 sean sean 0 2008-09-17 09:12 file3 sean@seanc:~/code/temp$ ./dir_list.pl $VAR1 = 'dir1'; $VAR2 = 'dir2'; $VAR3 = 'dir3';
so you can always have an up-to-date list of subdirectories, and the code looks prettier than having a big, long hard-coded list.

Changing the '-d' to a '-f' would give you a list of files, so you could adapt that to get a list of directories, then get a list of filenames or check for the presence of a particular file.