Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 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 > Libraries

    Hash::Type 1.08

    Download button

    No screenshots available
    Downloads: 331  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.0/5)
    5 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Laurent Dami | More programs
    Perl Artistic License / FREE
    March 12th, 2008, 11:29 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Hash::Type description

    Hash::Type module contains pseudo-hashes as arrays tied to a "type" (list of fields).

    Hash::Type module contains pseudo-hashes as arrays tied to a "type" (list of fields).

    SYNOPSIS

    use Hash::Type;

    # create a Hash::Type
    my $personType = new Hash::Type(qw(firstname lastname city));

    # create and populate some hashes tied to $personType
    tie %wolfgang, $personType, "wolfgang amadeus", "mozart", "salzburg";
    $ludwig = new $personType ("ludwig", "van beethoven", "vienna");
    $jsb = new $personType;
    $jsb->{city} = "leipzig";
    @{$jsb}{qw(firstname lastname)} = ("johann sebastian", "bach");

    # add fields dynamically
    $personType->add("birth", "death") or die "fields not added";
    $wolfgang{birth} = 1750;

    # More complete example : read a flat file with headers on first line
    my ($headerline, @datalines) = map {chomp; $_} ;
    my $ht = new Hash::Type(split /t/, $headerline);
    foreach my $line (@datalines) {
    my $data = new $ht(split /t/, $line);
    work_with($data->{someField}, $data->{someOtherField});
    }

    # an alternative to Time::gmtime and Time::localtime
    my $timeType = new Hash::Type qw(sec min hour mday mon year wday yday);
    my $localtime = new $timeType (localtime);
    my $gmtime = new $timeType (gmtime);
    print $localtime->{hour} - $gmtime->{hour}, " hours difference to GMT";

    # comparison functions
    my $byAge = $personType->cmp("birth : -num, lastname, firstname");
    my $byNameLength = $personType->cmp(lastname => {length($b) length($a)},
    lastname => 'alpha',
    firstname => 'alpha');
    showPerson($_) foreach (sort $byAge @people);
    showPerson($_) foreach (sort $byNameLength @people);

    # special comparisons : dates
    my $US_DateCmp = $myHashType->cmp("someDateField : m/d/y");
    my $FR_InverseDateCmp = $myHashType->cmp("someDateField : -d.m.y");

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    pseudo-hashes | list of fields | Perl module | pseudo-hashes | arrays | fields

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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