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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.