Okay so I am an ass yet again. I did try it on my system before
I rambled and the tr did not work, so I must have had a dumb little typo.
Just for kicks I benchmarked the s/// vs tr/// since they
seem to do the same in this reguard:
use Benchmark;
$str = "\n#\n#\nSTUFF\n#\n#\n";
timethese(1000000, {
's' => sub { $a = $str; $a=~s/\n/ /g; },
'tr' => sub { $a = $str; $a=~tr/\n/ /; }
});
RESULTS:
Benchmark: timing 1000000 iterations of s, tr...
s: 11 wallclock secs (11.22 usr + 0.00 sys = 11.22 CPU)
tr: 3 wallclock secs ( 3.61 usr + 0.00 sys = 3.61 CPU)
The moral of the story: Use tr/// where you can.
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.