Following Perl Cookbook, created 'seen-hashes' for each list
# loop through master file to populate @master
for (@master) { $seen_master{$_} = 1; }
# read directory holding source files to populate @sources
for (@sources) { $seen_sources{$_} = 1; }
Then, ask whether master list is subset of source file list.
$subset_status = 1;
for (@master) {
unless (exists $seen_sources{$_}) {
$subset_status = 0;
last;
}
}
Wrote similar code to keep track of demonstration Perl scripts.
Soon got tired of repeating code for seen-hashes and subsets.
Previous | Back to start of show | Next |
Slide: 3 seenhash_subset | © 2004-18 James E. Keenan |