Two reasons to dislike the eval come to mind immediately:
  1. You are firing up the compiler over and over again to parse Perl code, when in fact the only part that is changing is the indicies and the depth of those. That means you're using a very general pile of code to handle a well-known predictable subset, and you'll burn far too much CPU to do that in the long run.
  2. More specifically here, you aren't escaping things like ` and { in the directory names, so you'll get invalid compilations from time to time, which you aren't checking for. These could also be potential security holes, since I merely have to create a directory with a name like `my-proggy` and you'll now be executing it! Shame.
I consider any use of runtime eval to be a red flag during a code review session. There really has to be no other way to do something, and let me tell you, there's almost always more than one better way to do it.

-- Randal L. Schwartz, Perl hacker


In reply to RE: RE: RE: "du" to hash by merlyn
in thread "du" to hash by splinky

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.