I need to send a command to UNIX that copies a log file and renames it with a variable in my Perl program. I know how to send commands to UNIX:
print `cp x.txt y.txt';
which works fine...but if I have the variable a to rename the file with:
print `cp x.txt $a_log.txt`
the error message comes up when I run the Perl script dbi:
Name "main::a_log" used only once: possible typo at dbi line 146. Use of uninitialized value in concatenation (.) or string at dbi line +146.
Any suggestions for using perl variables to rename a file with UNIX commands? I've also looked into the system() and exec() commands but have not come up with anything that works.

In reply to Using UNIX commands inside Perl scripts, with Perl variables by Anonymous Monk

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.