Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Substring giving strange results on $1 with utf8

by Khen1950fx (Canon)
on Aug 07, 2012 at 02:45 UTC ( #985866=note: print w/ replies, xml ) Need Help??


in reply to Substring giving strange results on $1 with utf8

I tried it with a different twist, using perl-5.17.2:

#!/usr/bin/perl BEGIN { $| = 1; $^W = 1; } use autodie; use strictures 1; use common::sense; open my $PL, '>', 'utf2.pl' or die $!; print {$PL} << '__PL__'; binmode STDIN, ":utf8"; binmode STDOUT, ":encoding(UTF-8)"; while (defined(my $line = <ARGV>)) { if (my($word) = $line =~ /^(.+)$/) { my $one = substr($word, 0, 1); my $w_one = substr($word, 0, 1); print "'$one' = 'one'\t at $line" if $one eq $1; print "'$w_one' = 'w_one'\t at $line" unless $w_one eq $1; } } __PL__ open my $OUT1, '>', 'utf1' or die $!; print {$OUT1} map chr hex, qw/61 61 c5 99 0a c4 8d 0a 61 61 c5 99 0a/; close $OUT1; open my $OUT2, '>', 'utf2' or die $!; print {$OUT2} map chr hex, qw/c4 8d 0a 61 61 c5 99 0a c4 8d 0a/; close $OUT2; system "$^X utf2.pl < utf1"; print "\n"; system "$^X utf2.pl < utf2";
Does that help?


Comment on Re: Substring giving strange results on $1 with utf8
Download Code
Replies are listed 'Best First'.
Re^2: Substring giving strange results on $1 with utf8
by Anonymous Monk on Aug 07, 2012 at 03:45 UTC

    I tried it with a different twist, using perl-5.17.2: ... Does that help?

    How do you think that helps?

    The code no longer demonstrates the perl bug, how can that help?

    Typical Khen1950fx nonsense, poke the code with a stick and post the changes

      Typical AnonymousBug nonsense:);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985866]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-07-31 03:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls