If I understand you correctly, you store data in complex structures that are difficult for you to manipulate. The reason you are asking for types like NoSQL is because you need an easy way to store and process your data.
Then it's time to roll up your sleeves and find out Object Oriented Perl .
Creating Perl objects is a good way to handle complex data structures, and it's really not that hard to learn. I usually write classes on the fly and simply declare them at the end of my program.
This is the data structure that you had in your original post as a company class:
package Company; sub new { my $class = shift; my $name = shift; my $location = shift; my $self = {}; bless $self, $class; $self->Name($name); $self->Location($location); return $self; } sub Name { my $self = shift; my $name = shift; if ( defined $name ) { $self->{NAME} = $name; } return $self->{NAME}; } sub Location { my $self = shift; my $location = shift; if ( defined $location ) { $self->{LOCATION} = $location; } return $self->{$LOCATION}; }
That's all. Now I can easily create and manipulate my companies, without worrying about how to manipulate hash hashes or try to remember exactly how I structured my data:
# Read in all of the companies from $company_file into @company_list open my $company_fh, "<", $company_file; my @company_list; while ( my $line = <$company_fh> ) { chomp $line; my ($name, $location) = split /:/, $line; my $company = Company->new( $name, $location ); push @company_list, $company; } close $company_fh;
Later, I can manipulate my companies as follows:
#Print out all Chinese Companies for my $company ( @company_list ) { if ( $company->Location eq "China" ) { say $company->Name . " is located in China."; } }
source share