
お世話になります。
Unicodeの文字プロパティの使い方を学ぶために、以下のようなスクリプトをUTF-8で保存しました。
============
#! /bin/perl
#
# utf8_unireg.pl
use 5.010;
use strict;
use warnings;
use utf8;
binmode STDOUT, ":encoding(shift_jis)";
my $str = "a:b:c:";
say join "|", ($str =~ /\p{ASCII}/g);
say join "|", ($str =~ /\p{AsciiAlpha}/g);
sub AsciiAlpha {
return <<END;
0041005A# A-Z
0061007A# a-z
END
}
============
実行するとこうなります。
============
C:\Perl\perl>utf8_unireg2.pl
a|:|b|:|c|:
Can't find Unicode property definition "AsciiAlpha" at C:\Perl\perl\utf8_unireg2.pl line 14.
============
\p{AsciiAlpha}というプロパティの作成に失敗しているようです。。
なぜか分かりますでしょうか?
よろしくお願いします。
ありがとうございます!
自作プロパティの場合IsまたはInが必要なんですね。
これ、5.12のときはIs、Inがなくてもできたようです。
★
C:\Perl\perl>type utf8_unireg2.pl
#! /bin/perl
#
# utf8_unireg.pl
use 5.010;
use strict;
use warnings;
use utf8;
binmode STDOUT, ":encoding(shift_jis)";
my $str = "a:b:c:";
say join "|", ($str =~ /\p{AsciiAlpha}/g);
sub AsciiAlpha {
return <<END;
0041 005A # A-Z
0061 007A # a-z
END
}
C:\Perl\perl>perl utf8_unireg2.pl
a|b|c
C:\Perl\perl>perl -v
This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread
Copyright 1987-2010, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
C:\Perl\perl>
★
ところが、5.16になってからは、(Is|In)が必要になったようです。
★
C:\Perl\perl>perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2012, Larry Wall
Binary build 1603 [296746] provided by ActiveState http://www.ActiveState.com
Built Mar 13 2013 11:29:21
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
C:\Perl\perl>type utf8_unireg2.pl
#! /bin/perl
#
# utf8_unireg.pl
use 5.010;
use strict;
use warnings;
use utf8;
binmode STDOUT, ":encoding(shift_jis)";
my $str = "a:b:c:";
say join "|", ($str =~ /\p{AsciiAlpha}/g);
sub AsciiAlpha {
return <<END;
0041 005A # A-Z
0061 007A # a-z
END
}
C:\Perl\perl>perl utf8_unireg2.pl
Can't find Unicode property definition "AsciiAlpha" at utf8_unireg2.pl line 13.
C:\Perl\perl>type utf8_unireg2.pl
#! /bin/perl
#
# utf8_unireg.pl
use 5.010;
use strict;
use warnings;
use utf8;
binmode STDOUT, ":encoding(shift_jis)";
my $str = "a:b:c:";
say join "|", ($str =~ /\p{IsAsciiAlpha}/g);
sub IsAsciiAlpha {
return <<END;
0041 005A # A-Z
0061 007A # a-z
END
}
C:\Perl\perl>perl utf8_unireg2.pl
a|b|c
★
昔動いたプログラムが動かなくなったので、Perlの仕様変更でしょうね。。
ありがとうございました。
No.2
- 回答日時:
仕様としては, 5.10 のときでも「In」または「Is」で始まることが必要だったようです.
実装としていつ「In」または「Is」を要求するようになったのかは探せていませんが.
参考URL:http://perldoc.perl.org/5.10.0/perlunicode.html# …
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- Perl perlでリテラル値はメモリにどのように格納されているか? 1 2023/01/15 20:45
- Perl perlをバージョンアップしたら、今まで正常に動いていたプログラムが、エラーになってしまった 3 2022/10/05 15:44
- Perl Windows10においての『Perl』のプログラムについて 1 2022/05/09 16:04
- Perl Perlのエラーについてご教授ください。初心者です。 CGIを別サーバに移したところ、Perlのバー 5 2023/05/31 10:48
- その他(プログラミング・Web制作) awkのtoupper() 1 2022/10/21 20:39
- JavaScript JAVASCRIPT 2 2022/04/15 15:10
- その他(プログラミング・Web制作) laravel 本番環境でメールが送れません。 1 2023/02/17 17:57
- Perl Perl の外部モジュールの利用方法 3 2022/07/10 18:34
- CGI perlで書いたcgiでsqliteの使い方を教えてください 2 2023/05/08 21:29
- CGI -T(汚染モード)でメールが送れません 1 2022/06/12 14:11
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
INDIRECT 横に再度抽出したい
-
テキストファイルで提出とは?
-
perlプログラミング 空白行削除
-
Perlのエラーについてご教授く...
-
perlをバージョンアップしたら...
-
Wallpaper Engineでおすすめの...
-
P.Cのシングルチューナーとダブ...
-
#!/usr/bin/perlで書きだしたCG...
-
perlのflock関数でロックをかけ...
-
AI sisterとは、偽物の人ですか?
-
bashスクリプト
-
ファイルアイコンの左下に緑の□...
-
perlについての質問
-
perlについての質問
-
Perlで特定文字列から特定文字...
-
openした後、closeしないでプロ...
-
perl の open について教えてく...
-
Perl言語について。
-
ファイルをディレクトリ分配の...
-
アルファベットに付いて質問し...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
Perl cgiの文字化けを直したい ...
-
【エラー】Unrecognized character
-
Perl UTF8で出力
-
perlでuse utf8でsjisのファイ...
-
perlの自作ライブラリについて
-
Perl:Unicodeプロパティ作れない
-
perlのmysqlで文字化けをする、...
-
does not map to shiftjis は解...
-
sedの動作
-
Perlを用いて、XMLファイルの中...
-
消費税の計算で 税込価格から...
-
Perl utf8上でshiftjisをデコード
-
perlのLWP::Simpleでgrepの値が...
-
perlで新規ファイルを作成でき...
-
utf-8のCSVをshift_jisに変換し...
-
Perlでのファイル出力における...
-
HTTP::Request::Common qw(POST...
-
[Perl]Shift-JISのXMLを解析する場
-
[perl5.8] utf8で文字出力する...
-
ファイル出力をUTF8Nではなくて...
おすすめ情報