Dear brethren,
please help me understand either
- what is meant °
- what I'm missing
- if this a bug
from perlop#Quote-and-Quote-like-Operators
\x{263A} [1,8] hex char (example shown: SMILEY)
\x{ 263A } Same, but shows optional blanks inside and
adjoining the braces
DB<55> p join ",",map {ord} split //, "\x{ 41 }"
+
0
+
DB<56> p join ",",map {ord} split //, "\x{41}"
+
65
+
DB<57> p join ",",map {ord} split //, "\x{263A}"
+
9786
+
DB<58> p join ",",map {ord} split //, "\x{ 263A }"
+
0
+
DB<59> p "\x{41}"
+
A
+
DB<60> p "\x{ 41 }"
+
^@
tested with strawberry perl 5.032001 on win
Question: In which way is this
"Same, but shows optional blanks inside and adjoining the braces" ?
update
°) OK - ironically - reading the footnotes help
https://perldoc.perl.org/perlop#%5B1%5D
Note that any escape sequence using braces inside interpolated constructs may have optional blanks (tab or space characters) adjoining with and inside of the braces, as illustrated above by the second \x{ } example.
[1]
The result is the character specified by the hexadecimal number between the braces. See "8" below for details on which character.
Blanks (tab or space characters) may separate the number from either or both of the braces.
Otherwise, only hexadecimal digits are valid between the braces. If an invalid character is encountered, a warning will be issued and the invalid character and all subsequent characters (valid or invalid) within the braces will be discarded.
If there are no valid digits between the braces, the generated character is the NULL character (\x{00}). However, an explicit empty brace (\x{}) will not cause a warning (currently).
update
and activating warnings shows the bug, somehow the blank is not recognized.
DB<65> use warnings; "\x{ 263A }"
+
Non-hex character ' ' terminates \x early. Resolved as "\x{00}" at (e
+val
update
different warnings by version ... this is getting weirder and weirder
- ActiveState 5.24
C:\tmp>%PERL% -w
print $];
print "\x{ 41 }";
Illegal hexadecimal digit ' ' ignored at - line 2.
__END__
5.024001
- Strawberry 5.32
C:\tmp>%PERL_532% -w
print $];
print "\x{ 41 }";
Non-hex character ' ' terminates \x early. Resolved as "\x{00}" at -
+line 2.
__END__
5.032001
could someone please test this on linux?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.