Some suggestions and thoughts:

  1. Although I can't be certain, it looks like you're not using strict. Always use warnings; use strict;!!
  2. opendir( DIR, $sd) || die; would better with a lexical handle and the error message: opendir(my $dh, $sd) || die "couldn't opendir $sd: $!";
  3. Your opens would be better and safer with the three-argument form, lexical filehandles, and error handling: open (my $fh, '<', $dots[$a]) or die "couldn't open $dots[$a]: $!";
  4. The condition "$sd\/$filename" =~ /\/\./ will not just match (i.e. skip) .dotfiles, it'll skip any filenames that contain /. anywhere. For example, if $sd happens to contain that string someday, all files will be rejected. The condition $filename=~/^\./ would skip only filenames that begin with a dot and so that's probably better.
  5. I find the name @dots a little strange since it contains only files that don't begin with a dot?
  6. The last file of @dots is opened and read twice. An alternative would be to read <FILE> into a temporary array and store that into @foo, and into @foo2 when appropriate. Or you could move the special treatment of $dots[-1] outside of the loop (that would also have the stylistic advantage that the loop variable $a could be eliminated, e.g. for my $dot (@dots) { open (my $fh, '<', $dot) ...).
  7. I think the condition $a+1 eq @dots is more clearly written as $a==$#dots.

In reply to Re^2: Question about warnings and arrays by Anonymous Monk
in thread Question about warnings and arrays by james28909

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.