develooper Front page | perl.perl5.porters | Postings from January 2019

[perl #133782] length($^R) sometimes wrong

Thread Previous
Hauke D
January 19, 2019 13:45
[perl #133782] length($^R) sometimes wrong
Message ID:
# New Ticket Created by  Hauke D 
# Please include the string:  [perl #133782]
# in the subject line of all future correspondence about this issue. 
# <URL: >

Hi everyone,

This oneliner fails, when it most likely shouldn't:

  perl -e 'while( "\N{U+E4}bc" =~ /(..?)(?{$^N})/g )
           { length($^R)==length("$^R") or die }'

A slightly longer test program (attached) shows that on the second 
iteration, length($^R) is reporting 2 instead of the expected 1. It 
seems to have something to do with UTF8 strings, since it works fine on 
non-UTF8 strings.

Tested on several versions of Perl on Linux and Windows (down to 5.8.9).

-- Hauke D

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About