This is kind of a newbie question:
I'm trying to pull some text from a file, replace certain flags with variables from my script, and print the whole string of text with the replaced variables to an external process. I have the variable replacement down, but when I print the string, I see all of the special characters (\n specificially) in one big long string. I'd like the text to function just as it would when doing something like:
print SMBCLIENT "Hi there/n";
I'd appreciate any pointers/suggestions!
I'm including only a snippet of my much longer script.
open (MESSAGE, "/print_quota/windows/quota_message"); while (<MESSAGE>){ s/USER-LOGIN/$login/; s/PAGES-PRINTED/$pages/; if($pagestate eq "duplex"){ s/PAGESTATE/double sided/; } elsif ($pagestate eq "simplex"){ s/PAGESTATE/single sided/; } s/PRINTER/$printer/; s/QUOTA-USED/$quota/; s/POST-QUOTA/$report[2]/; s/ORIGINAL-QUOTA/$report[1]/; s/PRINTER/$printer/; s/MULTIPLIER/$multiplier/; open (SMBCLIENT, "|/usr/bin/smbclient -U Print_Quota -M $report[0] + -I $hostip[0]"); print SMBCLIENT "$_"; close SMBCLIENT; } close MESSAGE;
The file I'm reading from looks like this:
This is a test. Print quotas have yet to be fully implemented!\n\nYou, + USER-LOGIN, have printed PAGES-PRINTED page(s) PAGESTATE on the prin +ter \"PRINTER\".\n\nYou used QUOTA-USED credits on this print job, an +d you currently have POST-QUOTA quota credits left of your original O +RIGINAL-QUOTA.\nThe printer \"PRINTER\" is worth MULTIPLIER quota cre +dit(s).
As you may have guessed, this is a print accounting script.

In reply to A string from a file by Grand_Phallus

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.