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?
-
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.
|