YAML::MLDBM - Use tied hash db-s with Python and Ruby


    use YAML::MLDBM;

    my $h = YAML::MLDBM->new('./my_dbm_file');

    $h->{'@INC'} = \@INC;
    $h->{'%ENV'} = \%ENV;

    use Data::Dumper;
    print Dumper $h;


This module is similar to MLDBM except that it stores data internally as YAML, instead of Data::Dumper or Storable. By doing this, you can create tied hash DBM databases that can be used seamlessly in Python or Ruby applications. That's because those languages also have YAML and DBM modules. As other languages get YAML support, you should be able to use YAML::MLDBM with them as well.

This module is a wrapper around MLDBM, but you open a DBM file using the new() method, instead of using a tie. new() will return a reference to a tied hash.

You can also use YAML as a serialization method for MLDBM itself:

    use MLDBM qw(SDBM_File YAML);
    use Fcntl;
    tie %h, 'MLDBM', './my_dbm_file', O_CREAT|O_RDWR, 0640 or die $!;
    $h{'@INC'} = \@INC;
    $h{'%ENV'} = \%ENV;
    use Data::Dumper;
    print Dumper \%h;

This has the same affect, but is more verbose. It does offer you more control if you want it though.


See MLDBM, AnyDBM_File and YAML for more information.


Brian Ingerson <>


Copyright (c) 2003 Brian Ingerson. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.