Skip to content

Latest commit

 

History

History
182 lines (112 loc) · 4.62 KB

warnings.pod

File metadata and controls

182 lines (112 loc) · 4.62 KB

NAME

warnings - ��御�������ʃ⑥������茯炊�眼����� Perl �����í�違��

SYNOPSIS

use warnings;
no warnings;

use warnings "all";
no warnings "all";

use warnings::register;
if (warnings::enabled()) {
    warnings::warn("some warning");
}

if (warnings::enabled("void")) {
    warnings::warn("void", "some warning");
}

if (warnings::enabled($object)) {
    warnings::warn($object, "some warning");
}

warnings::warnif("some warning");
warnings::warnif("void", "some warning");
warnings::warnif($object, "some warning");

DESCRIPTION

The warnings pragma is a replacement for the command line flag -w, but the pragma is limited to the enclosing block, while the flag is global. See perllexwarn for more information.

warnings �����í�違����壔����潟����潟����í�ゃ�潟����í�� -w ��勛舟�����������с����� �����������������勉����í�違�壔�違�㏍�若����˨�ŝ�勉�с�������������勉����í�違����奝�������������� �����㏍����壔�̹��絎���������障����� ��眼�ŝ�������宴�� perllexwarn ���荀���⓾��������������

If no import list is supplied, all possible warnings are either enabled or disabled.

��ゃ�潟����若����ŝ�鴻�����筝������ŝ����翫����壔���櫝�純�ʒ����������⓾�勤⑥�����������鴻�˨�������� ��≦�鴻�˨�������������障�����

A number of functions are provided to assist module authors.

��������ゃ����勰�∽�違�壔����≪�吾�ャ�若�˩����������勖����í����������障�����

use warnings::register

Creates a new warnings category with the same name as the package where the call to the pragma is used.

�����í�違�������若�喝�冴�������������宴�若�吾����������������勖�違����� 茘☗����˨����眼�ŝ�若��篏���������障�����

warnings::enabled()

Use the warnings category with the same name as the current package.

�憜����勉�������宴�若�吾����������������勤⑥�����˨����眼�ŝ�若��篏帥����障�����

Return TRUE if that warnings category is enabled in the calling module. Otherwise returns FALSE.

��若�違�������≪�吾�ャ�若�������с����勤⑥�����˨����眼�ŝ�若�������鴻�ŝ����亥��鐚�TRUE鐚����菴������障����� ��������с�ŝ�������医�緒��FALSE鐚����菴������障�����

warnings::enabled($category)

Return TRUE if the warnings category, $category, is enabled in the calling module. Otherwise returns FALSE.

��若�違�������≪�吾�ャ�若�������ц⑥�����˨����眼�ŝ�種��$category鐚���������鴻�ŝ����亥�� 鐚�TRUE鐚����菴������障����� ��������с�ŝ�������医�緒��FALSE鐚����菴������障�����

warnings::enabled($object)

Use the name of the class for the object reference, $object, as the warnings category.

��ŝ����吾�с�壔����ŝ����<�㋘�潟�刻��$object鐚���勉�壔�í�劫�����茘☗����˨����眼�ŝ� ��������☖戎�����障�����

Return TRUE if that warnings category is enabled in the first scope where the object is used. Otherwise returns FALSE.

�����勉�ŝ����吾�с�壔�����篏帥����������������勉�鴻�潟�若�������с����勤⑥�����˨����眼�ŝ� ��������鴻�ŝ����亥��鐚�TRUE鐚����菴������障����� ��������с�ŝ�������医�緒��FALSE鐚����菴������障�����

warnings::warn($message)

Print $message to STDERR.

STDERR ��� $message �����阪�������障�����

Use the warnings category with the same name as the current package.

�憜����勉�������宴�若�吾����������������勤⑥�����˨����眼�ŝ�若��篏帥����障�����

If that warnings category has been set to "FATAL" in the calling module then die. Otherwise return.

�����������若�違�������≪�吾�ャ�若�������с����勤⑥�����˨����眼�ŝ�若��"FATAL"���荐㊤����������⓾����� ��ŝ����違��腟�篋�鐚�die鐚������障�����

warnings::warn($category, $message)

Print $message to STDERR.

STDERR ��� $message �����阪�������障�����

If the warnings category, $category, has been set to "FATAL" in the calling module then die. Otherwise return.

�����������若�違�������≪�吾�ャ�若�������ц⑥�����˨����眼�ŝ�種��$category鐚����"FATAL"��� 荐㊤����������⓾�������ŝ����違��腟�篋�鐚�die鐚������障�����

warnings::warn($object, $message)

Print $message to STDERR.

STDERR ��� $message �����阪�������障�����

Use the name of the class for the object reference, $object, as the warnings category.

��ŝ����吾�с�壔����ŝ����<�㋘�潟�刻��$object鐚���勉�壔�í�劫�����茘☗����˨����眼�ŝ� ��������☖戎�����障�����

If that warnings category has been set to "FATAL" in the scope where $object is first used then die. Otherwise return.

���������$object �����������˩戎�����������鴻�潟�若�������с����勤⑥�����˨����眼�ŝ� ���"FATAL"���荐㊤����������⓾�������ŝ����違��腟�篋�鐚�die鐚������障�����

warnings::warnif($message)

Equivalent to:

罨<�勉����勉�̥�後�������障�����

if (warnings::enabled())
  { warnings::warn($message) }
warnings::warnif($category, $message)

Equivalent to:

罨<�勉����勉�̥�後�������障�����

if (warnings::enabled($category))
  { warnings::warn($category, $message) }
warnings::warnif($object, $message)

Equivalent to:

罨<�勉����勉�̥�後�������障�����

if (warnings::enabled($object))
  { warnings::warn($object, $message) }

See "Pragmatic Modules" in perlmodlib and perllexwarn.

"Pragmatic Modules" in perlmodlib ��� perllexwarn ���荀���⓾��������������