Perl question/assitance (not looking for an application)
$30-5000 USD
Concluído
Publicado há mais de 20 anos
$30-5000 USD
Pago na entrega
I use DB_File and SDBM for all of my database needs in Perl..mainly because I can't find any good perl-MySQL tutorials. All the tutorials I find are just for MySQL, but not how to use Perl with it. What I need someone to do is teach me how to sort a complex hash. Please read full description below.
## Deliverables
I use DB_File and SDBM for all of my database needs in Perl..mainly because I can't find any good perl-MySQL tutorials. All the tutorials I find are just for MySQL, but not how to use Perl with it. Anyway, I almost always store multiple values in tied hashes. For example: my %db; my $db = "[login to view URL]"; tie %db, "DB_File", "$db", O_CREAT | O_RDWR, 0644, $DB_BTREE or die "Cannot open file 'db': $!\n"; my $joined = join("::", $num, $ip, $time); $db{$url} = $joined; Then whenever I extract data, I split on :: into variables again. That's simple enough, the problem is I need to be able to sort on ANY variable split. For example, if in my database I had keys/values like: [login to view URL] 43::[login to view URL]::12355334543 [login to view URL] 23::[login to view URL]::5442234556 [login to view URL] 924:[login to view URL]::3221234565 Basically I use a URL as a key, then I use a NUMBER ($count):: an ip ($ip) :: time() ($time). I need someone to write me up a VERY VERY VERY basic example on how I could sort by any of $count, $ip, $time. To get an idea what I'm trying to do, please take a look at [login to view URL] . I want to make the table headers for COUNT, IP and TIME to be linked into [login to view URL] or ip or time Remember, the hash key and all the other data MUST be tied together some how. I can't just sort the varible and lose the rest. Please note: I've asked this question in two places: [login to view URL] [login to view URL] Your solution must be different than any proposed in those two links.. I need an easy-to-understand and implement way to do this, I don't understand array referencing so please refrain from that. In conclusion: I am looking for someone to write up a VERY easy to understand example on how to set a sort like this up and I'd like it to be as commented out as much as possible so I can better understand it. If I don't understand the script, the project isn't completed until we talk it over through here or in email until I understand why and how it works. (also: I'm not sure if it matters, but I need examples on how to sort numbers and strings since I'll be using this on other scripts as well).
## Platform
not dependent exactly.