I just tried that and it doesn't look like it changes too much from what you type in. Looking at the file that you are reading, does the text file contain the actual text "\n" (two characters) or does it contain a newline. If it contains the two separate characters, the characters won't ever get interpolated as a newline.
Something that will lighten the load of your swaps (especially on large documents) is to first delimit your swap in variables (instead of "PRINTER" put some special characters around it such as "__printer__"), and then swap in keys from a hash as in the following:
# set up a hash containing the values you want
my %SWAPS = ();
$SWAPS{printer} = $printer;
$SWAPS{quota} = $quota;
if($pagestate eq "duplex"){
$SWAPS{pagestate} = 'double sided';
}elsif ($pagestate eq "simplex"){
$SWAPS{pagestate} = 'single sided';
}
if( 1 ){
$SWAPS{multiplier} = 'some_multiplier';
}
# swap out things like __printer__ with $SWAPS{printer}
$msg =~ s/__(\w+?)__/$SWAPS{$1}/g;
This does only one parse on the string and is a little bit more controlled than doing the multiple swap thing.
my @a=qw(random brilliant braindead); print $a[rand(@a)];
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.