On Wed, 2002-07-10 at 10:17, Rupert Heesom wrote:
> I'm working with directories in which there should be a number of graphs
> files; one TIFF file, one PDF file.
>
> I'm wanting to find which TIFF files there is no corresponding PDF file for.
>
> One way to do this is to create 2 lists (arrays), one for all the TIFF files
> in a directory, the other list for all the PDF files in the same directory.
> Then to compare the 2 lists to find the missing PDF files.
>
> However, if there is a better way to do this (I'm new to Perl), can anyone
> let me know?
>
> If there _is_ no better way, what's some good perl code for a Win32 script?
>
> Regs
> Rupert Heesom
> Asst Distribution Engineer
> Adventist World Radio
Hmmm... My first thought is:
#!/usr/bin/perl
use strict;
my %exists;
opendir DIR, $ARGV[0] or die "Horrible death:$!";
foreach (readdir(DIR) {
next unless /pdf$/ or /tiff$/ or /tif$/;
(my $file = $_) =~ s/\.(pdf|tiff|tif)$//; #remove the extension
$exists{$file}++;
}
closedir DIR;
#print every base filename that only has one occurrence in $path
print join('\n', grep { $exists{$_} == 1 } keys %exists), "\n";
--
Today is Sweetmorn the 45th day of Confusion in the YOLD 3168
Pzat!
Missile Address: 33:48:3.521N 84:23:34.786W
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]