sub checkdir { (-e $_[0] and -d $_[0]) or return 1; return 0; } ... unless (checkdir $_) {
Why are you using a double negative to test for something instead of just testing for something? Why say "If not not directory" instead of "If directory"?
Why are you using stat twice when only once is required? What do you think that -e does that -d doesn't do? In other words, if -d is true then -e will always be true and if -d is false then it doesn't matter what -e is.
You should change:
unless (checkdir $_) {
in the readmail sub to:
if (-d $_) {
or simply:
if (-d) {
sub printhash { for (0...$#_) { if ($_ % 2) { print $_[$_] . "\n"; } else { print $_[$_] . ": "; } } } ... printhash %curmsg;
You are complicating something that is very easy to do with a hash. In readmail change:
printhash %curmsg;
to:
print "$_: $curmsg{$_}\n" for keys %curmsg;
while ($curline = <FH>) { if ($curline =~ /^Subject: /) { ... } else { next; } }
You have a next; at the end of the loop, but the only place the loop could go to now is back to the beginning so that is a bit redundant.
In reply to Re: My first Perl application! mailsumm.pl
by jwkrahn
in thread My first Perl application! mailsumm.pl
by gizmoguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |