feature - ��違�����罘���純�������鴻�˨����������í�違��
use feature qw(say switch);
given ($foo) {
when (1) { say "\$foo == 1" }
when ([2,3]) { say "\$foo == 2 || \$foo == 3" }
when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" }
when ($_ > 100) { say "\$foo > 100" }
default { say "None of the above" }
}
use feature ':5.10'; # loads all features available in perl 5.10
use v5.10; # implicitly loads :5.10 feature bundle
��≪��絖���������⓾����������㏍�違�í�����紕������������ŝ�����Perl �����違��������羈����菴遵����������������壔�� ��勰����壚���櫝�純�с����� �����勉����í�違����壔����ŝ�鴻�壔�����絨������������号��������箴������障����� ��違��������羈�罕�����������𡉴��罕������勖�違����������潟�壔��use feature 'foo'
��ф����劫����������� ��ï����� feature �����í�違�������鴻�潟�若�������˨�������翫����˨�勉�帥����若�鴻�������障����� (��������с����������勉����í�違����̹�≪�����������CORE::
�・��㊧����壠����⓾� Perl ��㏍�若�壔�若����吾�勉�≪�壔�祉�鴻�����箴������障�����)
(��㋘�㏍�激�˨�˨�ɱ�号��)
(箴������� use strict
��勉��������) �����勌����勉����í�違��������罕����feature �� ��㋘�㏍�激�˨�˨�ɱ�号����������<�障����� use feature qw(foo)
��壔�������勐�亥�鴻����������㏍����壔�勛����������障�с�勰����������� "foo" 罘���純����ñ���櫝�純�˨����障�����
{
use feature 'say';
say "say is available here";
}
print "But not here.\n";
罘���純�� no feature "foo"
���篏帥����������х�≦�鴻�˨����������������堺�ャ�障����� �����������障����㋘�㏍�激�˨�˨�ɱ�号����������<�障�����
use feature 'say';
say "say is available here";
{
no feature 'say';
print "But not here.\n";
}
say "Yet it is here.";
no feature
������罘���純�����絎���������˩戎�����������������í�˨����違�˨�若����˨�ŝ�祉����������障����� �����⓾�� 罘���純����≦�鴻�˨�����(��勰����с�ŝ��荀�羆�!)��˨�壔��no feature ':all'
��� 篏帥�c�⓾��������������
(��ñ���櫝�純�ʋ�����)
('say' 罘����)
use feature 'say'
��壔����潟�潟����ゃ�í�� Perl 6 綵√����� say
��∽�違�� �����鴻�˨�������������˩�������障�����
荅潟�������� "say" in perlfunc ��������с����⓾��������������
�����勖����純�� Perl 5.10 ��������ñ���櫝�純�с�����
('state' 罘����)
use feature 'state'
��壔����潟�潟����ゃ�í�� state
紊���違�������鴻�˨������������� 篌������障�����
荅潟�������� "Persistent Private Variables" in perlsub ��������с����⓾��������������
�����勖����純�� Perl 5.10 ��������ñ���櫝�純�с�����
('switch' 罘����)
WARNING: ��鴻����若�������������潟�井��膊�絖� �� 絎�薑������ŝ�勉�с�������勖����純��篏帥�����������腓榊����̥�≦�鴻�˨����ŝ��������茘☗�������榊�������障��:
no warnings "experimental::smartmatch";
use feature 'switch'
��壔����潟�潟����ゃ�í�� Perl 6 given/when 罕������� �����鴻�˨�������������˩�������障�����
荅潟�������� "Switch Statements" in perlsyn ��������с����⓾��������������
�����勖����純�� Perl 5.10 ��������ñ���櫝�純�с�����
('unicode_strings' 罘����)
use feature 'unicode_strings'
��壔��(use locale
��� use bytes
�� ��鴻�潟�若����ŝ����с�ŝ��������) �����勉�鴻�潟�若�������у��茵���������������⓾�勖��絖�������篏��� Unicode ��勤��������篏帥����������˨�潟�潟����ゃ�í�˩�������障����� ��������壩��絖������勐����◑;�憗�壠����眼����障�����; �����������í��茹i�������������������с�����
no feature 'unicode_strings'
��壔��Unicode ���羆������������⓾�������勉�� Perl ��˨����c�〠����������с�ŝ����������������ゃ����c����ʋ��絖�������荀�������篏帥������������������� 篌�腟援����� Perl ��勤��������篏帥����������˨�潟�潟����ゃ�í�˩�������障����� ��������壔����壔�����������腦���九����眼����������������̹��������綣����莎激�������������������障�������� (荅潟�������� "The "Unicode Bug"" in perlunicode ��������с����⓾��������������) �����勛����宴�˨�������������������㏍�違�í����� Unicode �����宴���櫝�醇�с����������ŝ����� use feature 'unicode_strings'
��壔����í�違����� 綣激�� ��с����障�����
�����勖����純�� Perl 5.12 ��������ñ���櫝�純�˨�ŝ����障�����; Perl 5.14 ��с�祉�弱������� 絎�茖���������障�����; Perl 5.16 ��� quotemeta
���絲上�������������������≦宍��������障��������
('unicode_eval' ��� 'evalbytes' 罘����)
unicode_eval
罘���純�勐�冴�с�壔��Perl ��� eval
��∽�違�����絖�������羝<�������������� ���絖���勖��絖������������☀��箴<�����use utf8
絎h�������∴�������障����� use utf8
��壔�鴻�壔�ŝ�������勉����潟�潟�若����c�潟�違��絎h�����������������絖���������� �����ゃ����勌研��潟�˨�勉�炊����潟��������������絖���勖��絖������с�壩����潟����������障�������� ��純�若�鴻����c�˨�帥�夌��罩≪�������障��; �����������������ゃ����勖��絖�������絲障����⓾�勉� �����潟����������������с����� ��純�若�鴻����c�˨�帥�������鴻�˨�����������������������������荅⓾�帥�壔����í�若����ŝ����障�����
evalbytes
罘���純�� evalbytes
��㏍�若�壔�若����������鴻�˨����障��; ��������壠����違�������〠検��������������勉�������ゃ����勖��絖������������☀��箴<����障����� ���絖������� 8 �����������勛����蚊�勐����眼�勖��絖������˨�障����⓾�������� die �����障����� ��純�若�鴻����c�˨�帥�� evalbytes
��勌賢��с�壠��篏������障��: ����������� 荅�箴<�����������絖������勌賢荳˨��絲障����☁�ñ����������障�����
���������篋���ゃ�勖����純�壠�宴�˨��罩翫兏����� eval
��∽�違��臀勉�������������������� ��勛����������⓾����障��; ��������˨��(絨���ŝ��������)篋���ゃ�勉����違�������������√����勉����㏍�違�í����� 紕������������ŝ�靎≦����˩信罩c����������������с����障�����:
-
eval
��壩��絖������喝����������潟�潟�若����c�潟�違�˩��絖������☎�違�ŝ����壔�����������茵������� �����˨�壠����違�������ゃ����勖��絖������������〠�宴����������˨�壩��絖���勖��絖������������〠�宴����障����� -
eval
��勌賢��ф����鴻�˨����������純�若�鴻����c�˨�帥�壔����í�� file ��鴻�潟�若����� ��潟�潟����ゃ�˨�������⓾����������˨�ゃ����⓾�ŝ�若�壔����障����� CPAN ��≪�吾�ャ�若�˨�с����� Semi::Semicolons ���箴���˨����障��:BEGIN { eval "use Semi::Semicolons; # not filtered here " } # filtered here!
evalbytes
��壔����喝��������������篏���������������˩信罩c����障��:use feature "evalbytes"; BEGIN { evalbytes "use Semi::Semicolons; # filtered " } # not filtered
���������篋���ゃ�勖����純�� Perl 5.16 ��������ñ���櫝�純�с�����
('current_sub' 罘����)
��������� __SUB__
�����若�壔�潟�����箴������障��; ��������夌憜����勉�泣����˨�若����潟�吾� ��ŝ����<�㋘�潟�鴻�������泣����˨�若����潟�勐����眼�с�� undef
���菴������障�����
�����勖����純�� Perl 5.16 ��������ñ���櫝�純�с�����
('array_base' 罘����)
�����勖����純�壔�㋘�㋘�激�若�� $[
紊���違��絲上�������障����� "$[" in perlvar ��� arybase ��������с����⓾�������������� ��������壔�������í�˨����с�壔�ŝ�潟�с����� use v5.16
(緇�菴違� "IMPLICIT LOADING" ������) ��勐�冴�с�夌�≦�鴻�˨�ŝ����障�����
�����勖����純�� Perl 5.16 �����������勐�������у�ñ���櫝�純�с����� 篁ュ����勉����若�吾�с�潟�с�壔��������絽御����ñ����������⓾����⓾�������勉����í�違����壔�������˨�ゃ���� 篏������ャ����障�������с��������
('fc' 罘����)
use feature 'fc'
��壔��Unicode ��潟�粋昭��帥��絎�茖������� fc
��∽�違�� �����鴻�˨�������������˨�潟�潟����ゃ�í�˩�������障�����
荅潟�������� "fc" in perlfunc ��������с����⓾��������������
�����勖����純�� Perl 5.16 ��������ñ���櫝�純�с�����
('lexical_subs' 罘����)
茘☗��: �����勖����純�壔�障��絎�薑������с��絎�茖���壠����ャ�勉����若�吾�с�潟�� Perl �� 紊���������������������障�������� �����勉�������������勖����純��篏帥�����������腓榊����̥�≦�鴻�˨����ŝ��������茘☗�������榊�������障��:
no warnings "experimental::lexical_subs";
��������壔��my sub foo
, state sub foo
, our sub foo
���羈���˨����� ��泣����˨�若����潟�勐��臂í�������鴻�˨����障����� 荅潟�������� "Lexical Subroutines" in perlsub ��������с����⓾��������������
�����勖����純�� Perl 5.18 ��������ñ���櫝�純�с�����
('postderef' ��� 'postderef_qq' 罘����)
'postderef_qq' 罘���純�壔�� 緇�臀勉����ŝ����<�㋘�潟�号��羈� ��勖����純����� 緇�臀勰��������緇�臀勉�鴻�˨�í�勉����ŝ����<�㋘�潟�鴻����������˨�壔�í�若��蘂�紊���医������� ��ñ���櫝�純�˨�ŝ�������������≦宍�����障����� 箴������違��罨<�勌����ゃ�勖�����膈�箴<�˨�ŝ����障��:
my $s = "[@{ $h->{a} }]";
my $s = "[$h->{a}->@*]";
�����勖����純�� Perl 5.20 ��������ñ���櫝�純�с����� Perl 5.20 ��� 5.22 ��с�壔����������壠��薑�������篏�臀勉�ャ����������⓾����⓾�� ���腓榊����̥�≦�鴻�˨����ŝ�������� Perl ��虁⑥��������阪�������⓾����障�����:
no warnings "experimental::postderef";
Perl 5.24 ��������������勖����純�勌戎�����壔����壔��茘☗�������阪�������ŝ����ŝ����障����������� experimental::postderef
茘☗����˨����眼�ŝ��(�����������≦�鴻�˨�������潟�若������� 篋������с�勉��������)絖������������障�障�с�����
'postderef' 罘���純�壔����������˨�壔�í�若��蘂�紊���医�������勐����眼�с� 緇�臀勉����ŝ����<�㋘�潟�号��羈���������鴻�˨�������������� Perl 5.20 ������ Perl 5.22 �� 篏帥�������⓾����障�������� �����������勉����若�吾�с�潟�с�壔��'postderef_qq' 罘���純�����罕���˨�����������篏帥���� experimental::postderef
茘☗�����綣����莎激�������障����� Perl 5.24 ��������������勖��羈���壔����壔��絎�薑������с�壔�ŝ����ŝ�c����������с�壔�ŝ����� ��鴻�潟�若��筝㏍�с�í����ʋ����純��絎h����������⓾����������̹�≪����������������⓾�� Perl ��潟�若���� �����鴻�˨�ŝ����障��������
('signatures' 罘����)
茘☗��: �����勖����純�壔�障��絎�薑������с��絎�茖���壠����ャ�勉����若�吾�с�潟�� Perl �� 紊���������������������障�������� �����勉�������������勖����純��篏帥�����������腓榊����̥�≦�鴻�˨����ŝ��������茘☗�������榊�������障��:
no warnings "experimental::signatures";
��������壔��罨<�勉�������ʋ��羈���˨����c�⓾�泣����˨�若����潟�勐����違����㋘�㏍�激�˨��紊���違� 絮������с�������������˨����障��:
sub foo ($left, $right) {
return $left + $right;
}
荅潟�������� "Signatures" in perlsub ��������с����⓾��������������
�����勖����純�� Perl 5.20 ��������ñ���櫝�純�с�����
('refaliasing' 罘����)
茘☗��: �����勖����純�壔�障��絎�薑������с��絎�茖���壠����ャ�勉����若�吾�с�潟�� Perl �� 紊���������������������障�������� �����勉�������������勖����純��篏帥�����������腓榊����̥�≦�鴻�˨����ŝ��������茘☗�������榊�������障��:
no warnings "experimental::refaliasing";
��������壔�ŝ����<�㋘�潟�鴻�吾�勌撮��ャ�˨�������ュ�������������鴻�˨����障��:
\$a = \$b; # $a and $b now point to the same scalar
\@a = \@b; # to the same array
\%a = \%b;
\&a = \&b;
foreach \%hash (@array_of_hash_refs) {
...
}
荅潟�������� "Assigning to References" in perlref ��������с����⓾��������������
�����勖����純�� Perl 5.22 ��������ñ���櫝�純�с�����
('bitwise' 罘����)
茘☗��: �����勖����純�壔�障��絎�薑������с��絎�茖���壠����ャ�勉����若�吾�с�潟�� Perl �� 紊���������������������障�������� �����勉�������������勖����純��篏帥�����������腓榊����̥�≦�鴻�˨����ŝ��������茘☗�������榊�������障��:
no warnings "experimental::bitwise";
��������壠����ゃ�勖��羣�������������篏�羲�膊�絖� (& | ^ ~
) ��������勉�ŝ����í�潟����� ��医�ゃ�������☖��莢˨����〠�宴����������˨�ŝ����� ��ŝ����í�潟�����筝�莢˨����〠��絖������������〠�宴����違��������������篁����羲�膊�絖� (&. |. ^. ~.
) ���絨���ャ����障����� �����������勉�壚撮��ャ�勌��腮� (&= |= ^= &.= |.= ^.=
) ��˨����ñ����������障�����
荅潟�������� "Bitwise String Operators" in perlop ��������с����⓾��������������
�����勖����純�� Perl 5.22 ��������ñ���櫝�純�с�����
(罘���純�勖��)
茲���違�勖����純�勉�障�������☀˛��粋昭�����������˨�壔��罘���純�勖�� (feature bundle) ��� 篏帥����障����� 罘���純�勖����勐�������˨�壔��絎������勖����純����阪�ャ�������������˨�潟�㏍�潟�����臀勉�������障�����
use feature ":5.10";
篁ヤ����勖����純�勖�������ñ���櫝�純�с��:
bundle features included
--------- -----------------
:default array_base
:5.10 say state switch array_base
:5.12 say state switch unicode_strings array_base
:5.14 say state switch unicode_strings array_base
:5.16 say state switch unicode_strings
unicode_eval evalbytes current_sub fc
:5.18 say state switch unicode_strings
unicode_eval evalbytes current_sub fc
:5.20 say state switch unicode_strings
unicode_eval evalbytes current_sub fc
:5.22 say state switch unicode_strings
unicode_eval evalbytes current_sub fc
:5.24 say state switch unicode_strings
unicode_eval evalbytes current_sub fc
postderef_qq
:default
�����壔��use feature
��� no feature
絎h����������鴻�˨�ŝ������� 罘���初��������茵◐憗����⓾����障�����
罘���純�勖����с�� 5.14.0
��� 0
��勉�������ɱ�壔����若�吾�с�潟�����絎������⓾����号���� ��������障�������� 罘���純�勖����壠����⓾�勐�壔����若�吾�с�潟�̹�≪����☗�����篋����篆�荐若�������⓾����障�����
use feature ":5.14.0"; # same as ":5.14"
use feature ":5.14.1"; # same as ":5.14"
(���藥���勤˛��粋昭���)
罘���純�勖�������������ц˛��粋昭������������Perl ���罘���純�勖��������藥���̬˛��粋昭��障������������� ��������鴻��膂≦����с�����
feature
�����í�違��������藥���̬˛��粋昭�����˨�壚����ゃ�勖�号�������������障��:
-
Perl ��勉�潟����潟����í�ゃ�潟��
-e
��ŝ����激�с�潟�勌撮���������-E
��ŝ����激�с�潟�� 篏睡����������翫����� ��������˨��������main ��潟�潟����ゃ�����篏�(��ゃ�障�����-E
���綣����膓���� 1 茵�������)�� �����勉����若�吾�с�潟�� Perl ��勖����純�勖����������鴻�˨�ŝ����障����� -
use VERSION
罕�������篏帥�c�⓾����㏍�違�í�����綽�荀�������������篏������� Perl �����若�吾�с� ��ɱ垩�����腓榊��������絎���������翫����� ��ゃ�障�����篁ヤ����勉�������˨��������:use v5.10.0;
���藥���勉����<�˩札筝���勉��������:
no feature ':all'; use feature ':5.10';
��ŝ�������������������с����� ���絨障�勐�壔����若�吾�с�潟�虁�ɱ�������˨����若�吾�с�潟�������������ゃ����������������˨�ŝ�c���������� 羈���������⓾��������������
���������腱紙����с�勤⑥���("use" in perlfunc ��������с����⓾�����������)�����帥�������������˨�� 篁ヤ����勉�������˨�������勉��絅純����������������障�����:
use 5.010;
��������с����������号�����緇���������障�����
荀�羆������������若�吾�с�潟�� Perl 5.10 �����������勐�翫�����篁c��������罘���純�勖�� ":default" ��� ��ɱ�������̬˛��粋昭��障����障�����