Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

gctaylor1's scratchpad

by gctaylor1 (Hermit)
on Sep 08, 2008 at 18:09 UTC ( [id://709826]=scratchpad: print w/replies, xml ) Need Help??

Here's my HoHoH example:
#!/usr/bin/perl #========================================================== # # FILE: hashref.pl # # USAGE: ./hashref.pl # DESCRIPTION: # NOTES: -- # CREATED: 11/09/2009 06:28:27 PM #========================================================== use strict; use warnings; use DBM::Deep; use Getopt::Long; use Data::Dumper; my $db = DBM::Deep->new( "foo2.db" ); my ($modify, $print, $dumper, $reghash, $adduser, $addmachine, $addk +eyvalue); GetOptions( "modify" => \$modify, "print" => \$print, "dumper" => \$dumper, "reghash" => \$reghash, "adduser" => \$adduser, "addmachine" => \$addmachine, "addkeyvalue" => \$addkeyvalue ); my $user = "user1"; my $machine = "machine1"; my $key = "key1"; my $value = "value1"; if ($reghash) { my %hash = ( abc => '123', xyz => '456' ); print %hash, "\n"; $hash{def} = '890'; print %hash, "\n"; } if ($modify) { $db->{$user} -> {$machine} -> {"$machine"."$key"} = "$machine"."$value +" } if ($adduser) { $db->{$user} = {$machine => {$machine.$key => "$machine"."$value"} } }; if ($addmachine) { $db->{$user} -> {$machine} = {"$machine"."$key"=> "$machine"."$value"} }; if ($addkeyvalue) { $db->{$user} -> {$machine} -> {"$machine"."$key"} = "$machine"."$value +" }; if ($print) { while ( my ( $outerkey, $value) = each %$db ) { print "The outer key is $outerkey. \n"; while ( my ( $key2, $value) = each %{ $db->{$outerkey} } ) { print " The machine key is $key2: \n"; foreach my $key ( keys %{ $db->{$outerkey}->{$key2} } ) { # my $value = ${ $db->{$outerkey}->{$key2}{$key}} print "\t$key $db->{$outerkey}->{$key2}{$key}\n" } print "\n"; } } } if ($dumper) { print Dumper $db; }
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-23 07:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found