X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FApp%2FLastmsg.pm;h=8d2cce57eb09d247c336dcd61711c9ed32a58d0d;hb=8d77279934f4257a0ea5c7f3ac29f99f00f0d5f1;hp=827cd364fef6365540cf428c09770b20ff1b4bd8;hpb=82af6c123c3cc37d8c4174dbb7e5180e067fd7dd;p=app-lastmsg.git diff --git a/lib/App/Lastmsg.pm b/lib/App/Lastmsg.pm index 827cd36..8d2cce5 100644 --- a/lib/App/Lastmsg.pm +++ b/lib/App/Lastmsg.pm @@ -12,12 +12,13 @@ use List::Util qw/max/; use POSIX qw/strftime/; our $OUTPUT_FILEHANDLE = \*STDOUT; -our $VERSION = '0.001'; +our $VERSION = '0.001002'; -our @DEFAULT_INBOX = ( - "/var/mail/$ENV{USER}", - "$ENV{HOME}/Maildir/", -); +our @DEFAULT_INBOX; +push @DEFAULT_INBOX, "/var/mail/$ENV{USER}" if exists $ENV{USER}; +push @DEFAULT_INBOX, "$ENV{HOME}/Maildir" if exists $ENV{HOME}; + +sub format_time { strftime '%c', localtime shift } sub run { my $config = Config::Auto->new(format => 'yaml')->parse; @@ -95,7 +96,7 @@ sub run { my $addrlen = max map { length } values %lastaddr; for (sort { $lastmsg{$b} <=> $lastmsg{$a} } keys %lastmsg) { - my $time = strftime '%c', localtime $lastmsg{$_}; + my $time = format_time $lastmsg{$_}; printf $OUTPUT_FILEHANDLE "%-${idlen}s %-${addrlen}s %s\n", $_, $lastaddr{$_}, $time; }