Next Trivial Utilities 64

sortby Overengineering

     # Return contents of context file as hash
     sub context {
       my $cf = context_file();
       local *CF;
       open CF, "<", $cf or croak "Couldn't open context file '$cf': $!; aborting";
       my %c;
       while (<CF>) {
         chomp;
         my ($k, $v) = split /:\s*/, $_, 2;
         $c{$k} = $v;
       }
       wantarray ? %c : \%c;
     }


Next Menu Copyright © 2012 M. J. Dominus