This should work

use strict; use warnings; my $address = 'myemail@whatever.com'; my $subject = "Comments Version: $version ID: $ID"; system( "mail $address -s '$subject' < blah6.txt" ) == 0 or die "mail failed: $?";
I made three changes to the code you posted:
  1. Eliminated the s/// line since escaping is required only in a double-quoted context, but above the @ is being given in a single-quoted context, so no variable interpolation occurs.
  2. I put the RHS of the assignment to $subject in double quotes, because in this case we do want interpolation (of $Version and $ID).
  3. In the argument to system I put $subject in single quotes, because otherwise the shell would interpret the various words in $subject as different arguments, as opposed to the single argument for -s
This is definitely a little quoting workout! You may want to read the docs on quoting, to best make sense of the above.

the lowliest monk


In reply to Re^5: System Command Issues by tlm
in thread System Command Issues by blanket

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.