Next Welcome to my ~/bin 58

sortby Overengineering

     sub profile {
       if (%profile) {
         return wantarray ? %profile : \%profile;
       }
       my $profile = profile_filename();
       open P, "<", $profile 
         or croak "Couldn't open profile file $profile: $!; aborting";
       local $_;
       my $next_line = <P>;
       while (defined $next_line) {
         my $cur_line = $next_line;
         $next_line = <P>;
         next if $cur_line =~ /^#/;
         while ($next_line =~ /^[ \t]/) {
           $cur_line .= $next_line;
           $next_line = <P>;
         }
         my ($key, $value) = split /:\s*/, $cur_line, 2;
         chomp $value;
         $profile{$key} = $value;
       }
       return wantarray ? %profile : \%profile;
     }
     sub profile_filename {
       $profile ||= $ENV{MH} || home_dir() . "/.mh_profile";
     }
     sub home_dir {
       $HOME ||= $ENV{HOME} 
             || (getpwuid($<))[7] 
             || croak "Couldn't determine home directory\n";
     }


Next Menu Copyright © 2005 M. J. Dominus