"B. Fongo" wrote:

> I have several groups of files in a directory, like:
>
> Mazda.1.jpg, Mazda.2.jpg, Mazda.2.jpg
> Toyota.1.jpg, Toyota.2.jpg, Toyota.3.jpg
> Voyager.1.jpg, Voyager.2.jpg, Voyager.3.jpg
> Etc. etc
>
> # First of, I'll get the list of all files.

Jumping in too fast here, I would say.  You make clear above that the individual
files are not uniform--they are compononents of sets of three.  That being the
case, why load them in an inappropriate data structure? Think instead of a way
to load an array or hash for each brand name.  Probably a hash for the outer
structure:

my $views = {};
while (<IN>) {
   my @name_elements = split /\./;
   $views->{$name_elements[0]} = {} unless  $views->{$name_elements[0];
   $pics->{$name_elements[0]}->{$name_elements[1]} = 1;
}

Then you can validate that the set of pictures for each brand is complete:
foreach $brand (keys %$views) {
   my $set = $views->{$brand};
   $complete_set->{$brand} = 1 if $set->{1} and $set->{2} and $set->{3};
}


Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to