> Thanks Peter, that will help.
> I am wondering if the use of anonymous hash and array
> may make more sense here than doing a bunch of `grep`.
> Can somebody show me how I would use it here?
This isn't anonymous, but here's how I'd tackle it:
### untested
my %dups;
my %totaldups;
foreach my $sfile( sort BY_NUM glob "$path/*" )
{
my $page = 1;
my $section = 1;
open(SFILE,$sfile) || die "Can't open $sfile : $!\n";
foreach my $line (<SFILE>)
{
$page++ if /some page match here/;
$section++ if /some section match here/;
if ( ($dup) = $line =~/(dup match here)/ )
{
$dups{$page}{$section}{$dup}++;
$totaldups{$dup}++;
}
}
close(SFILE);
}
foreach my $page (sort {$a <=> $b} keys %dups)
{
foreach my $section (sort {$a <=> $b} keys %$page)
{
foreach my $dup (sort keys %$section)
{
if ($$section{$dup} > 1)
{
# HERE's a DUP!
}
}
}
}
### REPEAT FOR %totaldups
### etc...
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs