I am very sorry to dump on your code like that jbush82. I realize not everyone codes at the same level and I try to dole out the advice in digestible pieces but I let pc88mxer get under my skin and you got caught in the crossfire.

As to your code, have you implemented some of the other suggestions given to clean up your code?

Perl has powerful list operators map, grep shift, unshift, push and pop. Studying the perldocs for these would help to unleash the power of perl to you. One book that has a particularly good treatment of these is "Intermediate Perl" by Schwartz, d foy, and Phoenix. They explain list operators better that I ever could.

In general, to build and add or remove from lists use push, pop, shift and unshift. To change, diplay or copy every element of a list use map(). To create a new list with selected element of a previous list use grep(). Use foreach() if it is the side-effects of operations on the list that are important and use map() and grep() if it's the returned elements of the list that are important.

Any time, in your code, you need to search a collection of items based on a name you should be thinking hash. Perl's hash datatype provides a powerful and efficient method of storing named containers that would take at least a page of C code to emulate. See perldata and perlreftut

I wrote a similar piece of code to check the md5 hash on a list of files where I use some of the list operators. The code is written for unix and doesn't need to keep a list of matches as yours needs but I think the techniques used there would translate well to your requirements. Note particularly that no indexing variables are used.


s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

In reply to Re^5: Uninitialized value in concatenation (.) or string? by starbolin
in thread Uninitialized value in concatenation (.) or string? by jbush82

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.