![]() |
Sorting entries in a DBM hash by one of the variables
Hi,
I have a slight problem in that I want to list all the entries in a DBM file. I'm fine with sorting my the key, but I want to sort by one of the variables in the value - I know how to do all of it with the exception of specifying which variable is in the value: if the key-value pair consists of the ID (the key) and a load of variables concatenated with §, presumably at some point I will need to split them - but then I don't know where and at which point I will need to say 'sort by this and not this.' I have searched around and can't find anything... Hope this makes sense to someone... Thanks. Chris |
Re: Sorting entries in a DBM hash by one of the variables
Topher wrote:
> I have a slight problem in that I want to list all the entries in a > DBM file. I'm fine with sorting my the key, but I want to sort by > one of the variables in the value This is one example that sorts by the second § separated "variable": my @sortedkeys = sort { ($dbmhash{$a} =~ /§([^§]*)§/)[0] cmp ($dbmhash{$b} =~ /§([^§]*)§/)[0] } keys %dbmhash; It might get you started. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl |
| All times are GMT. The time now is 06:14 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.