When you read the file into the array, you read the line terminators as well. Those line terminators start a new line in the textarea, too. When you interpolated the array into a string with -default=>"@source", perl used the value of $" (a space by default) to separate the elements. This is where the extra space came from on the second and subsequent lines.
There are a couple of ways I can think of to fix this. Choose one of these to suit your tastes.
- Use chomp @source to remove the newline characters before interpolating into the string. This will allow the textarea to rewrap the text.
- Set $" to an empty string before the interpolation. This will keep the current line breaks when loaded into the textarea. You might want to use local ($") = "" here. The local will reset $" back to its previous value when your program leaves the current scope.
---
print map { my ($m)=1<<hex($_)&11?' ':'';
$m.=substr('AHJPacehklnorstu',hex($_),1) }
split //,'2fde0abe76c36c914586c';
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.