I capture a series of fields, as an example:
and then use an auto-vivifying hash to act as a counter of the unique data set:my($ip,$name,$proto,$email) =~ /^(\S*) (\S*) (\S*) (\S*)$/;
Clearly this allows tracking the number of times a given NAME was used, along with the various IPs, and for each of those PROTOs, and finally EMAILs.$userdata{$name}{$ip}{$proto}{$email}++;
But this has a built-in order. I'd like to be able to allow a user-configurable ordering of that data, for example:
such that I could capture essentially as:@order = qw(ip name email proto)
essentially changing the primary, secondary, etc. key orders. Creating the many combinatorics to suit all cases isn't an option of course.$userdata{$order[0]}{$order[1]}{$order[2]}{$[order[3]}++; # which I want to result in ... $userdata{$ip}{$name}{$email}{$proto}++;
Can anyone suggest a mechanism to accomplish this that is a) fast, and b) not terribly memory intensive. The amount of data can be quite large, and is coming from a plain text file and not a DB.
Thanks in advance.
In reply to Configurable key orders by Smitty
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |