If you use $a instead of $alpha, then you won't get this message. ;)

I am using TinyPerl 5.8.0, so your code did not run on my PC, because you require Perl 5.12. Why do you do that? There are usually just small differences between versions, but if you could write a script that is compatible with older versions, then people with older machines could run your programs. So, I modified your code a little bit to make it run on my computer. For example, I changed the word "say" to "print" and I changed "require v5.12" to "use strict" so it runs fine now. I also changed the $alpha to $a Hehe

#!/usr/bin/perl use strict; use warnings; $a = chr(65); print "This is what Alpha looks like $a\n";

By the way, I would also like to show you a different way to accomplish the same output using the vec() function. Try this code:

#!/usr/bin/perl use strict; use warnings; $a = 'This is what Alpha looks like:'; # This instruction overwrites the 33rd # character in string $a with chr(65). # But since string $a is only 30 characters long, # it extends string $a with some spaces and then # writes chr(65) to position 32. The index starts # with 0, so "0" would be the first letter, and # "1" would be the second letter, and # "32" is the 33rd letter... vec($a, 32, 8) = 65; print $a, "\n";

In reply to Re: chr() function by harangzsolt33
in thread chr() function by catfish1116

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.