Several problems: First, you are assigning the output of a backtick shell command to $conf, but not testing to see if the command worked. Depending on what happens to be in your current working directory, that shell command might return an empty string. Did you happen to notice anything else on STDERR (which this initial backtick shell would produce, if those commands failed)?

(BTW, the error message you cited is caused by having an empty string to the left of the pipe symbol in a shell command.)

In any case, this next part is almost certainly not what you really want:

# changes a setting $conf = s/99/$num/;
I think you meant to use the "=~" operator there (to alter the contents of $conf, assuming it's not empty)? As it is, when the substitution fails, $conf is be set to empty string. (It would be set to "1" on success, but that would only happen if by chance $_ contains "99").

But even with the "=~" operator there, the next part doesn't make sense: if the initial backtick command worked as intended, $conf would contain a multi-line string. If you change a 99 in that string to something else, it's still multi-line, and I expect that putting it at the start of a pipeline in another backtick shell command would be a bad idea.

(Update: added clarification in first paragraph, fixed grammar in the second; also wanted to point out that the initial backtick command (cat; ls) should probably be replaced by using perl-internal operations: open/read the file, use a file glob or readdir; this would make the error handling better.)


In reply to Re: benchmarking problem by graff
in thread benchmarking problem by drawde83

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.