Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Hash::Mogrify 0.03

    Download button

    No screenshots available
    Downloads: 171  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Sebastian Stellingwerff | More programs
    Perl Artistic License / FREE
    March 26th, 2011, 14:57 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Hash::Mogrify description

    Perl extension for modifying hashes

    Hash::Mogrify is a Perl module that contains functions for changes parts of hashes, change/mogrify it's keys or it's values.

    The functions are flexible in design. The functions kmap, vmap and hmap return a hash/list in list context and a hash-reference in scalar context. The first argument to these functions is a code block to mogrify the hash, the second either a hash or a hashref.

    If a hash(list) is provided as an argument a new hash is created. When a hash-reference (e.a \%hash) is provided the original hash is changed.

    The function ktrans works similar to kmap, except that it takes a hashref as translation table instead of a codeblock.

    By default no function overwrites existing keys and warns about this when trying. this can be changed by setting the global or local bitmap. The global bitmap can be set on load by the following keys: :nowarning # do not warn about errors :dieonerror # die incase you're trying to override an existing key :force # override existing keys (overrrides :dieonerror). The local bitmap can be set by adding to the end of the function, there are the following constants: NOWARNING FORCE DIEONERR The local bitmap will completely override the global bitmap.

    More options might be provided in later versions.

    SYNOPSIS

     use Hash::Mogrify qw(kmap vmap hmap);
     # or :all
     or
     use Hash::Mogrify qw(kmap vmap hmap :force :nowarning :dieonerror);
     # to set global bitmaps
     or
     use Hash::Mogrify qw(:all :const);
     # also get constants for setting local bitmaps.

     my %hash = ( foo => 'bar',
     quuz => 'quux',
     bla => 'bulb',);

     my %newhash = kmap { $_ =~ s/foo/food/ } %hash;
     my $newhashref = vmap { $_ =~ s/bulb/burp/ } %hash;
     my $samehashref = hmap { $_[0] =~ s/foo/food/; $_[1] =~ s/bulb/burp/ } \%hash;

     ## setting local bitmaps
     my %newhash = kmap { $_ =~ s/foo/food/ } %hash, NOWARNING | FORCE;
     # to enable nowarning and force for this action.

     kmap { $_ =~ s/foo/food/ } \%hash, DIEONERR
     # to let kmap die on error.

     ktrans { foo => 'food' }, \%hash;
     # Change key foo into key food.



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    modify hashes | Perl module | Perl | hash | modifier

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM