previous | top | next

White Space Is Our Friend


Software That is Easy to Read is Easier to Maintain

#!/usr/bin/perl

package HashFromFile;

sub make {
    my ($class, %args) = @_;
    my $file = $args{filename};
    my $hash = {};

    open(FH, "< $file");

    while (my $line = <FH>) {
        if ($line =~ /^\s+$/) {
            next;
        }
        chomp($line);
        
        my ($key, $value) = split(/:/, $line);
        $hash->{$key} = $value;
    }

    close(FH);
    
    return $hash;
}

1;


Email: bschmaus@combinenet.com