| 1 |
#!/usr/bin/perl -l |
| 2 |
|
| 3 |
use Text::TabularDisplay; |
| 4 |
use Mail::Address; |
| 5 |
|
| 6 |
my @f = readfile("$ENV{'HOME'}/.mutt/aliases"); |
| 7 |
my $t = Text::TabularDisplay->new("alias", "address"); |
| 8 |
for (@f) { |
| 9 |
my @l = split; |
| 10 |
shift @l; |
| 11 |
my $alias = shift @l; |
| 12 |
my $addr = Mail::Address->new("@l"); |
| 13 |
$addr = $addr->format; |
| 14 |
$t->add($alias, $addr); |
| 15 |
} |
| 16 |
|
| 17 |
print $t->render; |
| 18 |
|
| 19 |
sub readfile { |
| 20 |
my $file = shift; |
| 21 |
my @lines; |
| 22 |
local *F; |
| 23 |
|
| 24 |
open F, $file or return; |
| 25 |
while(<F>) { |
| 26 |
chomp; |
| 27 |
push @lines, $_; |
| 28 |
} |
| 29 |
|
| 30 |
return @lines; |
| 31 |
} |