Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

gctaylor1's scratchpad

by gctaylor1 (Hermit)
on Sep 08, 2008 at 18:09 UTC ( #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
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-08-30 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls