Oh, ok, that's great. :)
Actually, hashes don't necessarily need to have values assigned to the elements. But in your case, it doesn't matter; either assign a value or don't. Here's an example:
my %hash;
while ( <DATA> ) {
chomp;
$hash{$_} = 1;
}
Or even:
my %hash = map { chomp; $_ => undef } <DATA>;
If you need to massage each line so that you have only the mac address, that is pretty easy to do too. The second example does slurp the file, so beware if your files are massive. Of course you'll have to have at least enough resources to hold all the mac addresses in memory anyway.
After reading that first file, and creating your hash, you can go through and use the hash values as flags to mark on each subsequent file if the mac address is found. At the end of each file read, check to see if you've flagged all hash keys, and each hash element that doesn't have its flag turned on, you can delete. Then reset all flags (or use a different flag for the next file), and so on.
It's just one way.
|