Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

linuxkid's scratchpad

by linuxkid (Sexton)
on Mar 03, 2012 at 04:41 UTC ( #957600=scratchpad: print w/ replies, xml ) Need Help??

Hierarchical DB System
Still Some work to do, but it's almost done.

#!/usr/bin/perl use YAML::Tiny; $iparse = YAML::Tiny->new(); %dbs; $dbtouse; %hoc = ( open => \&opendb, cdb => \$cdb, use => \&cdb, get => \&retrieve, retrieve => \&retrieve, value => \&setval, set => \&setval, save => \&save, quit => sub {exit;}, exit => sub {exit;}, ); print '`: ' if(not defined $ARGV[0]); COMMAND: while(<>) { chop($line = <STDIN>); ($command, @args) = split / /, $line; $args = join ' ', @args; $command = lc $command; if(defined $hoc{$command}) { $hoc{$command}->(@args); } else { print "ERROR: $command unknown!\n"; } print '`: ' if(not defined $ARGV[0]); next COMMAND; } sub opendb { $file = shift; $name = shift; $dbs{$name} = $iparse->read($file); } sub cdb { $name = shift; $dbtouse = \$dbs{$name}; } sub retrieve { } sub setval { } sub save { $file = shift; $dbtouse->write($file); }

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 exploiting the Monastery: (6)
As of 2014-10-01 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (41 votes), past polls