Skip to content

Latest commit

 

History

History
1349 lines (912 loc) · 35 KB

perldebtut.pod

File metadata and controls

1349 lines (912 loc) · 35 KB

NAME

perldebtut - Perl ��с�勉����������違�勉����ャ�若����ŝ�≪�

DESCRIPTION

perl �����������㋘�勌戎�����鴻��(�����⓾��) 荵初����ɾ換篁���������潟�� perl �����㏍�違�í���� �����������違�̹�≪�������������с��絖����������������羞宴�������掩����吾�勉����ゃ�潟�帥�с�����

perl ���罸���ヤ戎��c�⓾�������勉�˨��perl �����������㋘��篏帥����������˨�ゃ����☖�������ャ����ŝ���������� ������������篋冴�����絽吾�˨����������������障����� ��������壔����勉�������ŭ査�����<�勉�������勉����勉�с�����

use strict

��障����������˨��perl ��勉����㏍�違�í����������������違�������������˨�������������㋘������� 篏帥����������ŝ�����篋榊�������ャ����̥����眼�ŝ����勉�˨�������������˨�с����������������������ゃ�� ��������障����� ���������腓冴����������˨��"hello" �����������������勉�����膣���с�������馹������宴�������鴻�壔�ŝ�������� 腓冴����障��:

#!/usr/bin/perl

$var1 = 'Hello World'; # always wanted to do that :-)
$var2 = "$varl\n";

print $var2; 
exit;

��������壔����í�若�ŝ����潟�潟����ゃ�˨�������喝��茵���������障����������������������喝���������������� 莎激����ŝ����с��������; �����ŝ����<��"Hello World\n" �����壠����頫◐ず��������障�����; 筝���� (��潟�潟����ャ�若�帥��絨������������上�����������) ��������������̬������������������� ���篏������⓾����障����� ��������壔����壕�����絖����茵◐ず�����⓾����⓾�����������腥肴����勉�������̬����������勉�с����� 2 ��ゃ�勐����違����������������̬�������障��������絎������˨�� (��帥�ゃ�������鴻�勉��������) 3 ��ゃ�勐����違����������勉�с��:

$var1 = 'Hello World';
$varl = undef;
$var2 = "\n";

�����勛┏��勐�馹����茖�莇潟�������˨�壔����鴻�壔�ŝ�������勖�������勤����勐����� 'use strict;' ��� ��吾����� strict ��≪�吾�ャ�若�˨��絨���ャ�������������с��紊���違��篏帥�������˨�壠㐂荐���������������� 綣桁�吟�с����障�����

��������у��茵�������������perl ��� 3 ��ゃ�勖�ɱ㐂荐�紊���違�̹�≪����� 4 ��ゃ�勉����í�若�<����祉�若�吾�� ��с�障��; ��ŝ����ŝ�� 1 ��ゃ�勐����違�� 2 ��������с�������⓾�������������с��:

Global symbol "$var1" requires explicit package name at ./t1 line 4.
Global symbol "$var2" requires explicit package name at ./t1 line 5.
Global symbol "$varl" requires explicit package name at ./t1 line 5.
Global symbol "$var2" requires explicit package name at ./t1 line 7.
Execution of ./hello aborted due to compilation errors.     

�����������ŝ��! ��������⓾��������篆勖③��������������˨�������⓾�勐����違�����腓榊�����絎h����������������˨����������� ��鴻�壔�ŝ�������壚札筝���勉�������˨�ŝ����障��:

#!/usr/bin/perl
use strict;

my $var1 = 'Hello World';
my $varl = undef;
my $var2 = "$varl\n";

print $var2; 
exit;

���������������������筝�綺☗��茵����������������羈������с����壔��茵������障��(��������壠幻�� ��������������с��):

> perl -c hello
hello syntax OK 

��������☗��茵������������������壔�� "\n" ���茵◐ず��������障��������絨���ŝ����������ŝ������� �����������障����� ��潟�潟����ゃ�˨�������鴻�壔�ŝ�������� '$varl' (���絖� 'l' ��с��) �����������������������������˨�ŝ����� ������ $varl ��� $var1 ���紊���眼�������医�馹���虁В羆冴����障�����

Looking at data and -w and v

(�����若�帥�勤����鴻�� -w ��� v)

�����������с����㋚����˨��������紊���違����ャ�c�⓾����������若�帥��������������篏帥����翫����̥�ャ����˨��?

#!/usr/bin/perl 
use strict;

my $key = 'welcome';
my %data = (
        'this' => qw(that), 
        'tom' => qw(and jerry),
        'welcome' => q(Hello World),
        'zip' => q(welcome),
);
my @data = keys %data;

print "$data{$key}\n";
exit;                               

��壔����������̬�������障��; ���羈������с����� (perl -c scriptname) ��勐�����絎�茵������⓾�帥�������� ��障�����腥肴����������冴�障�����! ��泣�若�����

��������т����㋜����ŝ����������井��羈���勌����ゃ�壔��print ��������ɾ�宴�˨�������ゃ����違����障����⓾�� �����若�帥�������ŝ�潟����������翫����勉����с����壔��菴遵����������������с��:

print "All OK\n" if grep($key, keys %data);
print "$data{$key}\n";
print "done: '$data{$key}'\n";

��������☗�������⓾����障��:

> perl data
All OK     

done: ''

��������潟�若��������荀���ゃ����������⓾��������荀���〠⤴���荀������˨�ŝ�c�⓾����������������������障��; 筝���������☁��������羈����荅⓾����障����������� ��������壔����潟����潟����í�ゃ�潟�� perl ��� '-d' ��ŝ����激�с�潟��筝���������������ч����級����� 菴������ャ�������������с��:

> perl -d data 
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(./data:4):     my $key = 'welcome';   

��������с�������������壔����鴻�壔�ŝ��������絲障����☎����粋昭��� perl �����������㋘�� 莎桁����������������с����� ��������壠��茵���潟�若����勖�������勤����у��罩≪����⓾����ュ�����緇���c�⓾����障�����

�����̹�蚊�������˨����í�������c�⓾����������㋘�������������������ャ����������с��������: ���茯� 'quit' ��� 'exit' ��с�壔�ŝ��������������絖� 'q' �����帥�ゃ�������⓾�����������:

DB<1> q
>

��������с�������潟����若����違�í�⓾�潟�������祉�c�⓾����障�����

help

(�����˨��)

��鴻�壔�ŝ��������絲障����⓾�����筝�綺⓾����������㋘��莎桁�������⓾�������˨����<����ャ�若��荀���⓾�帥�障����� �����˨�������若�喝�冴����˨�虁����違�勖�号�������������障��: ���膣���� 'h' ��壔����˨����ŝ�鴻���� 荀�膣������阪��������'|h' (�����ゃ��-h) ��壔����˨����������若�吾��(紊���� 'more' ��� 'less') ��̹�����������緇���� 'h h' (h-腥榊��-h) ��壔����˨����鴻�壔�ŝ�若�喝��篏���� 茵◐ず�����障����� 篁ヤ����虁��膣������若�吾�с��:

D1h

List/search source lines:               Control script execution:
 l [ln|sub]  List source code            T           Stack trace
 - or .      List previous/current line  s [expr]    Single step
                                                              [in expr]
 v [line]    View around line            n [expr]    Next, steps over
                                                                   subs
 f filename  View source in file         <CR/Enter>  Repeat last n or s
 /pattern/ ?patt?   Search forw/backw    r           Return from
                                                             subroutine
 M           Show module versions        c [ln|sub]  Continue until
                                                               position
Debugger controls:                       L           List break/watch/
                                                                actions
 o [...]     Set debugger options        t [expr]    Toggle trace
                                                           [trace expr]
 <[<]|{[{]|>[>] [cmd] Do pre/post-prompt b [ln|event|sub] [cnd] Set
                                                             breakpoint
 ! [N|pat]   Redo a previous command     B ln|*      Delete a/all
                                                            breakpoints
 H [-num]    Display last num commands   a [ln] cmd  Do cmd before line
 = [a val]   Define/list an alias        A ln|*      Delete a/all
                                                                actions
 h [db_cmd]  Get help on command         w expr      Add a watch
                                                             expression
 h h         Complete help page          W expr|*    Delete a/all watch
                                                                  exprs
 |[|]db_cmd  Send output to pager        ![!] syscmd Run cmd in a
                                                             subprocess
 q or ^D     Quit                        R           Attempt a restart
Data Examination:     expr     Execute perl code, also see: s,n,t expr
 x|m expr       Evals expr in list context, dumps the result or lists
                                                               methods.
 p expr         Print expression (uses script's current package).
 S [[!]pat]     List subroutine names [not] matching pattern
 V [Pk [Vars]]  List Variables in Package.  Vars can be ~pattern or
                                                              !pattern.
 X [Vars]       Same as "V current_package [Vars]".
 y [n [Vars]]   List lexicals in higher scope <n>.  Vars same as V.
For more help, type h cmd_letter, or run man perldebug for all docs. 

�����⓾��紊������勖祁箙宴����������ŝ����激�с�潟����������障��! ��������虁�������勉�祉�ð�ŝ����壔�������障�������������������������鴻�⓾�˨�ゃ����⓾����c�◐�ャ���������� �����⓾����������с��������罐純����������������障��!

��障����ャ�c�⓾�������鴻����������ゃ����勉�潟����潟�������������障����� �����勖����鴻�с�壚�������勉�í�ゃ����í�ŝ��篏帥�c�⓾����������虁�������⓾����ŝ����с�������������� 'M' ��夌憜�◑˛��粋昭��障����⓾�������≪�吾�ャ�若�˨�������若�吾�с�括�ɱ垩��茵◐ず������ 筝���� 'm' ��壔�<�純��������茵◐ず������'S' ��壚札筝���勉�������˨��(�����帥�若�潟�˨����c��) �����⓾�勉�泣����˨�若����潟��茵◐ず�����障����� 'V' ���'X' ��壔����������宴�若�吾�鴻�潟�若�������������帥�若�潟�˨����c�☗�狗����с�������� 紊���違��茵◐ず�����障�����

DB<2>S str 
dumpvar::stringify
strict::bits
strict::import
strict::unimport  

X' ��������勤Κ蕁����篏帥�������˨�壔��������絎�絖�($@%)���篏帥��綽�荀���壔�������障�����; ������ 'name' �����ュ�������⓾�����������:

DM<3>X ~err
FileHandle(stderr) => fileno(2)    

��馹������宴�����絨������ŝ����㏍�違�í����������c�⓾��篁���í����˨�������������������⓾����若�帥�� ��í�勉�������˨����c�⓾�������勉�����荀���������������⓾����������������������冴����⓾�������������� ��障����������˨���憜��篏�臀� (�����勐�翫����с�壔�潟�若����勖�������勤��) ��勉�潟�若�����荀���⓾�帥�障��������; 'v' ���篏帥����障��:

DB<4> v
1       #!/usr/bin/perl
2:      use strict;
3
4==>    my $key = 'welcome';
5:      my %data = (
6               'this' => qw(that),
7               'tom' => qw(and jerry),
8               'welcome' => q(Hello World),
9               'zip' => q(welcome),
10      );                                 

茵���ɱ�� 4 ��˨�������勉�壠�í����˨�ŝ�������ゃ�潟�帥�с��篁���í����˨�������勉�����腓冴����⓾����障����� ��������˨�潟�若�����荀������˨�壔�������� 'v' �����帥�ゃ�������障��:

DB<4> v
8               'welcome' => q(Hello World),
9               'zip' => q(welcome),
10      );
11:     my @data = keys %data;
12:     print "All OK\n" if grep($key, keys %data);
13:     print "$data{$key}\n";
14:     print "done: '$data{$key}'\n";
15:     exit;      

��������⓾�����茵���ɱ�� 5 ��������活����������ŝ�����'l 5' �����帥�ゃ�������障�� (腥榊�純��羈���������⓾�����������):

DB<4> l 5
5:      my %data = (

�����勐�翫�����荀���������������勉�壔����障��紊������壔�������障����������������<�������勰����虁��羝<����勉� 篏������若�吾�˨����ŝ�����絎鴻����������勉�с��'l' ��壔����⓾����������с����� 荀���⓾�������贋�����絎�茵������������������⓾����������������˨�ŝ�祉�������������˨�壔�����筝���� '.' ��� ��帥�ゃ�������障��:

DB<5> .
main::(./data_a:4):     my $key = 'welcome';  

茵◐ず��������⓾�����茵���� 罨<�� 絎�茵���������������������⓾����������勉�с����障�� 絎�茵���������⓾����障�������� 緇���c�⓾����������ф��絖� 'p' ���篏帥�c�☗����違��茵◐ず��с����障�������������勖����鴻�с� 茵◐ず�����������勉�夌Ã(��ɱ��臂�)��ゃ�������с����� ��������鴻����������壔��'s' ���篏帥�c�〠❶��勐��茵��櫝�醇����̹�蚊����������с��:

DB<6> s
main::(./data_a:5):     my %data = (
main::(./data_a:6):             'this' => qw(that),
main::(./data_a:7):             'tom' => qw(and jerry),
main::(./data_a:8):             'welcome' => q(Hello World),
main::(./data_a:9):             'zip' => q(welcome),
main::(./data_a:10):    );   

��������ф�������� ($key) 紊���違��荀���������������с����障��:

DB<7> p $key 
welcome 

茵� 13 �����☎����勐�贋����ŝ�勉�с�����絖� 'c' ���篏帥�c�⓾��篁�綺⓾�壔��筝��������������� �����㋘�若�壔����ゃ�潟�����筝�������������茵������泣����˨�若����潟����水�ャ�������������с�������障� ��蚊����⓾�������障��������:

DB<8> c 13
All OK
main::(./data_a:13):    print "$data{$key}\n";

�����с�����('All OK' ���茵◐ず�����������贋��)�����������������⓾��篏�罐㏍�勤����鴻�勛�雁���� ���罩≪����障�������� 篏����莎激����⓾�������勉�����荀������������˩����ゃ�勐����違��茵◐ず������������������������������ ��с����障��:

DB<9> p $data{$key}

�����障����������障�������������������激�ャ��荀���⓾�帥�障��������:

DB<10> p %data
Hello Worldziptomandwelcomejerrywelcomethisthat 

DB<11> p keys %data
Hello Worldtomwelcomejerrythis  

�����若�������������壔����⓾��茯㏍�帥����������������������勉�с�壔�������障�����; ��������☀Κ����� ��������ャ�≪�� (h h) ���篏帥��������'x' ��潟����潟�����荀�莨若�帥����������������с��:

DB<12> x %data
0  'Hello World'
1  'zip'
2  'tom'
3  'and'
4  'welcome'
5  undef
6  'jerry'
7  'welcome'
8  'this'
9  'that'     

��������壔����障����í����˨�壔�ŝ����障�����; ��������˨�� 2 ��ゃ�� "welcome" �����������障�������� ��í�������㏍�若�с�í�������ゃ�����腓冴�������勉����ŝ����������̹����������潟����勌��荀с�с�� �����勐�翫�������鴻��綵鴻�̥����ゃ����勉�с�壔�������障�������� ��������с�勖����壔�������若�炊�������吾�� ��ŝ����<�㋘�潟�� ���篏帥����������с��:

DB<13> x \%data
0  HASH(0x8194bc4)
   'Hello World' => 'zip'
   'jerry' => 'welcome'
   'this' => 'that'
   'tom' => 'and'
   'welcome' => undef  

��ŝ����<�㋘�潟�鴻��絎������˨����潟����������⓾����ゃ�������宴�c�⓾����������勉��荀������障�������� ��壔�í�若����壠�������������鴻�с�����������篁������勛�勛����˨�奝�������c�������勉�с�����; 'and jerry' ������茯���с�壔�ŝ�����2 ��ゃ�勐�ャ����勐��茯���������〠�宴�������⓾����障��; 緇���c�⓾��2 ��ょ����勉�������激�ユ�������勉�≪�í�ゃ�<�潟����������������勉�с�����

'-w' ��ŝ����激�с�潟�壔�������˨�ゃ����〠�������⓾����������勉�с����������˩戎��c�⓾�������違�� 紊������勐�馹������������c�⓾�������⓾����障�����:

> perl -w data
Odd number of elements in hash assignment at ./data line 5.    

��壔�í�若�����篆勖③�����障��: 'tom' => q(and jerry)�����������☗��絎�茵�������������篁�綺⓾� 篋���渇�������勐�阪�����緇���������障��:

> perl -w data
Hello World

��������˨����������� 'x' ��潟����潟�����������菴������ц����⓾�帥����������������壩�㋚�������������с�� �����鴻����������ŝ����<�㋘�潟�鴻��絎������ŝ�ŝ����吾�с�壔�������ŝ����吾�с�壔����勌����� - ��潟����潟���� 筝������������勉�壚����с�� - 罐純����������潟�������障��:

膂≦����ŝ�ŝ����吾�с�壔�����篏���c�⓾��荀���⓾�帥�障��������; ��障�������������㋘��莎桁�������障��: ��������� STDIN ������篏���������勐就��勐�ュ�����荀�羆���������勉�с��篏������≦佬��ŝ����� - ��若�� - ��� ��ュ�������障��:

> perl -de 0
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   0

��������с��茲���域�����篏帥�c�⓾����勐�眼�с�ŝ����吾�с�壔�����罕�膀������障�� (��������壔�鴻�í����激�ャ��羈���������⓾�����������):

DB<1> $obj = bless({'unique_id'=>'123', 'attr'=> \
cont:   {'col' => 'black', 'things' => [qw(this that etc)]}}, 'MY_class')

��������☀����⓾�帥�障��������:

DB<2> x $obj
 0  MY_class=HASH(0x828ad98)
                'attr' => HASH(0x828ad68)
        'col' => 'black'
        'things' => ARRAY(0x828abb8)
                0  'this'
                1  'that'
                2  'etc'
                'unique_id' => 123       
DB<3>

箴水�í�с��������? ��������с�祉�������í�ŝ����с�� eval ��с����⓾����<����c����������潟�若�����罩h�頫◐憗�� �����ゃ�障�с��絎�薑���с����障�����

DB<3> @data = qw(this that the other atheism leather theory scythe)

DB<4> p 'saw -> '.($cnt += map { print "\t:\t$_\n" } grep(/the/, sort @data))
atheism
leather
other
scythe
the
theory
saw -> 6

��潟����潟��絮ユ⑳���荀���������ŝ�����'H' �����帥�ゃ�������障��:

DB<5> H
4: p 'saw -> '.($cnt += map { print "\t:\t$_\n" } grep(/the/, sort @data))
3: @data = qw(this that the other atheism leather theory scythe)
2: x $obj
1: $obj = bless({'unique_id'=>'123', 'attr'=>
{'col' => 'black', 'things' => [qw(this that etc)]}}, 'MY_class')
DB<5>

篁ュ����˩戎��c����潟����潟�����膵違��菴������������翫����壔��������膃⓾��篏帥����障��: '!':

DB<5> !4
p 'saw -> '.($cnt += map { print "$_\n" } grep(/the/, sort @data))
atheism
leather
other
scythe
the
theory
saw -> 12

��ŝ����<�㋘�潟�鴻�˨�ゃ����⓾�勉�������ŝ�������宴�˨�ゃ����⓾�� perlref ��� perlreftut ��� �����с����⓾��������������

Stepping through code

(��潟�若�������鴻��������絎�茵�������)

篁ヤ����壩��羂���◑櫐��������紊�������������膣���ŝ����㏍�違�í����с�������壔����馹������宴����⓾����障��:

#!/usr/bin/perl -w
use strict;

my $arg = $ARGV[0] || '-c20';

if ($arg =~ /^\-(c|f)((\-|\+)*\d+(\.\d+)*)$/) {
        my ($deg, $num) = ($1, $2);
        my ($in, $out) = ($num, $num);
        if ($deg eq 'c') {
                $deg = 'f';
                $out = &c2f($num);
        } else {
                $deg = 'c';
                $out = &f2c($num);
        }
        $out = sprintf('%0.2f', $out);
        $out =~ s/^((\-|\+)*\d+)\.0+$/$1/;
        print "$out $deg\n";
} else {
        print "Usage: $0 -[c|f] num\n";
}
exit;

sub f2c {
        my $f = shift;
        my $c = 5 * $f - 32 / 9;
        return $c;
}

sub c2f {
        my $c = shift;
        my $f = 9 * $c / 5 + 32;
        return $f;
}

��ŝ���������櫐�����������羂���吾�勐�������壩ィ羝㋘��������腟�������菴������勉��紊掩�������障����� 篁ヤ����壔�í����ŝ�������с��:

> temp -c0.72
33.30 f

> temp -f33.3
162.94 c

�����鋇�莢˨����⓾����障�����! ��������с�潟�若����˨����㋘�若�壔����ゃ�潟�������祉����������⓾��篏����莎激����⓾�����������荀������������ �����������㋘�у��茵������⓾�帥�障����� �����㋘�若�壔����ゃ�潟����壔�������������㋘��筝㊥�㏍�ŝ����у��茵���������������勉����í�違�с�� �����㋘�若�壔����ゃ�潟�������育��������������絎�茵�������罩≪����⓾�������ŝ��絲乗º��勉�������˨����㏍�潟�������� ��冴����障����� ���絽吾�勌戎�����с�壔�������������勉����������㋘�潟����潟����壠�������̥�∴���������������������� 茖遵����潟�若�����罧������⓾��絎������с�� - ���������箙演����������������障�����������

my ($in, $out) = ($num, $num);
$DB::single=2; # insert at line 9!
if ($deg eq 'c') 
        ...

> perl -d temp -f33.3
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(temp:4): my $arg = $ARGV[0] || '-c100';     

'c' �����帥�ゃ�������⓾�����膣���˩�������祉�������������������㋘�若�壔����ゃ�潟����障�х�������障��:

DB<1> c
        main::(temp:10):                if ($deg eq 'c') {   

綣����膓������☀;腓冴�潟����潟����т����í����˨�����������荀���障��:

DB<1> v
7:              my ($deg, $num) = ($1, $2);
8:              my ($in, $out) = ($num, $num);
9:              $DB::single=2;
10==>           if ($deg eq 'c') {
11:                     $deg = 'f';
12:                     $out = &c2f($num);
13              } else {
14:                     $deg = 'c';
15:                     $out = &f2c($num);
16              }                             

��������☖��篏帥�c�⓾�������ゃ��茵◐ず��������障��:

DB<1> p $deg, $num
f33.3

��潟�㏍�潟�勌�������⓾�������í�勤����˨����ャ�勉����㋘�若�壔����ゃ�潟�����臀勉�������������с����障��; ��泣����˨�若����潟�����菴���c�⓾�������違�������勉����������с����� 17 茵���勉��篏帥����������˨����⓾�� ��������������������т����☗��罩≪����������������障��:

DB<2> b 17

���������絲障��������綽���壔�������障�����������筝�荀� 'L' ��潟����潟�����篏帥����������с����í� �����㋘�若�壔����ゃ�潟�������祉�������������⓾�����������荀���������������с����障��:

DB<3> L
temp:
                17:            print "$out $deg\n";
                break if (1)     

�����㋘�若�壔����ゃ�潟����������ゃ�������������˨�� 'B' ���篏帥�����������羈���������⓾��������������

��������с�泣����˨�若����潟�勌賢�����ャ�c�⓾�������������˨����障��; 篁������虁����ɱ垩�с�壔�ŝ����� ��泣����˨�若����喝�����篏帥����障��; �����勐�����篁������ŝ�c�⓾�壔����ŝ����帥�� 'v' ���篏帥����障��:

DB<3> c f2c
main::f2c(temp:30):             my $f = shift;  

DB<4> v
24:     exit;
25
26      sub f2c {
27==>           my $f = shift;
28:             my $c = 5 * $f - 32 / 9; 
29:             return $c;
30      }
31
32      sub c2f {
33:             my $c = shift;   

��������� 29 茵���勉����勰����˨�泣����˨�若����潟�������������������� ��激�潟�違�˨�鴻�������� ��������� ��翫�����'s' ��潟����潟�����篏帥����障����������泣����˨�若����潟�壠��茵���������������í�� ��泣����˨�若����喝�������壩����祉����ŝ����������� 'n' ��潟����潟���� ��鴻����������ŝ�若����若�с����障����� �����������������勐�翫����˨�壔�������� 29 茵���障�ч�蚊����⓾�������障��:

DB<4> c 29  
main::f2c(temp:29):             return $c;

��������☀�������ゃ��荀���⓾�帥�障��:

DB<5> p $c
162.944444444444

��������壠�������������c��膈������с�����������荐���壩③��������������̬�������障����� 羲�膊�絖���勐�ɱ�����篏����篏�������茵���c�⓾�������勉�с�����������? ���荐���̹�≪����⓾����勌����勐櫝�醇�с��荅⓾����⓾�帥�障��:

DB<6> p (5 * $f - 32 / 9)
162.944444444444

DB<7> p 5 * $f - (32 / 9) 
162.944444444444

DB<8> p (5 * $f) - 32 / 9
162.944444444444

DB<9> p 5 * ($f - 32) / 9
0.722222222222221

:-) ��������壔�����篌若�⓾����障��! �����������������х�㋝�ŝ�勤�������ゃ����祉����������⓾��'r' ���篏帥�c�⓾�泣����˨�若����潟�����菴������障��:

DB<10> $c = 5 * ($f - 32) / 9

DB<11> r
scalar context return from main::f2c: 0.722222222222221

��壔����������с��; ��鴻�壔�ŝ�������勖��緇���障�у��茵������⓾����障��������:

DB<12> c
0.72 c 
Debugged program terminated.  Use q to quit or R to restart,
        use O inhibit_exit to avoid stopping after program termination,
        h q, h R or h O to get additional info.   

絎������勉����㏍�違�í����勐�馹���勉�����茵���������ュ�☎舟(筝�莇潟����⓾����������c�������水�ャ�����)��� ��純����⓾��腟���������с�����

Placeholder for a, w, t, T

(a, w, t, T ��勉�������勉����㋘�若�鴻����˨��)

��≪�壔�激�с�潟��紊���違�勛�h�������鴻�帥����壔����㋘�若�鴻�ŝ��: TODO ��ŝ�鴻����с�����

a 

w 

t 

T

REGULAR EXPRESSIONS

(罩h�頫◐��)

罩h�頫◐憗����í�勉�������̬�������������ャ�������������������障��������? 篁ヤ����勉�������˨�������˨�� perl ��� DEBUGGING �����í�遺�������с�潟�潟����ゃ�˨�����綽�荀���� ��������障��:

> perl -Dr -e '/^pe(a)*rl$/i'
Compiling REx `^pe(a)*rl$'
size 17 first at 2
rarest char
 at 0
   1: BOL(2)
   2: EXACTF <pe>(4)
   4: CURLYN[1] {0,32767}(14)
   6:   NOTHING(8)
   8:   EXACTF <a>(0)
  12:   WHILEM(0)
  13: NOTHING(14)
  14: EXACTF <rl>(16)
  16: EOL(17)
  17: END(0)
floating `'$ at 4..2147483647 (checking floating) stclass
  `EXACTF <pe>' anchored(BOL) minlen 4
Omitting $` $& $' support.

EXECUTING...

Freeing REx: `^pe(a)*rl$'

��㋚����̥�ャ����������c����с�����? :-) 罩h�頫◐憗�勐��篏���̹�≪�����荅括完��˨�ゃ����⓾�壔��perlre, perlretut ������ (筝�菴違�� BOL ��� CURLYN ��ŝ�í��)筝����茘違�ŝ�í����˨��茹h˛��������˨�壔�� perldebguts ��������с����⓾��������������

OUTPUT TIPS

(��阪����勐�����)

�����í�若�㏍�違�������勐����⓾�勐�阪�����緇���⓾��荀ɱ����� OS ��勉����������<�ŝ�潟�違� ��<����祉�若�吾��紊宴����ŝ����������˨�������˨�壔����鴻�壔�ŝ�������勖�������˩札筝���勉�������ʃ����� ��水�ャ����⓾�����������:

$|=1;   

���������紜����膓���������㏍�違����<�ゃ�˨�勖��絨障����h����������˨�壔��(��潟����潟����í�ゃ�潟�����):

tail -f $error_log

�����⓾�� die ��若�喝�冴����������潟����í�˨�若����潟�у�蚊����������í����с����í�勉������� ��若�喝�冴�������⓾�������������ャ����勉����������с��; perlvar ��˨�������ŝ�������宴����������障��:

BEGIN { $SIG{__DIE__} = sub { require Carp; Carp::confess(@_) } }

STDOUT ��� STDERR �����<�ゃ�˨����潟����˨�勉�ŝ����ゃ�㋘�壔����̹�≪�����罕������ŭ梢��í� �����壔�������壔�� perlopentut ��� perlfaq8 ��̬��菴違�������⓾����障�����

CGI

�����ュ��緇���<�������㏍�潟�������������í����������育����������������勉����������������ŝ�������⓾� CGI �����㏍�違�í����吾�勛亜�����ŝ����潟����������⓾�� CGI �����潟����潟����í�ゃ�潟�����絎�茵���������������˨��篁ヤ����勉�������ŝ����勉��荅⓾����⓾�����������:

> perl -d my_cgi.pl -nodebug 

�����<����� CGI ��� perlfaq9 ��˨�壔����c��紊������勖����宴����������障�����

GUIs

(GUI)

��潟����潟����í�ゃ�潟�ゃ�潟�帥�若����с�若�鴻�� emacs ��≦宍���絲��・��̥輝�����������⓾����⓾�� vi ��ゃ�潟�帥�若����с�若�鴻����������障�����

��������������������������⓾����潟����潟����í�ゃ�潟�у��茵�������綽�荀���壔�������障�����; ��������ゃ����� GUI ��勰�御����≪����������障����� �����������勉����������������壔�������⓾�鴻�˨�若�純�˨��紊���違�勌����̥Щ��������������◒�ï���� ��⓾�c�潟����⓾�������˨�若�潟�˨����勉����若�帥�������潟����������������� 'x $varname' �� ��帥�ゃ�������ŝ����⓾�������������с�� :-)

��鴻�˩札筝���勉����勉�勤昇������茯帥�鴻�⓾�帥�⓾�����������:

ptkdb �����˨����ゃ�潟����������㋘�勉�������� perlTK �����若�鴻�勉�í�������

ddd �����若�粋;腓冴����������

PerlDevKit ��� PerlBuilder ��� NT ��堺����с��

羈������������� (�����������������勌����勉����勉�̹�≪�������������ŝ�������宴�������������医晃�����с��)���

SUMMARY

(��障�����)

use strict ��� -w ���篏帥�c�⓾�í�������c�☀�壔����潟�若����c�潟�違��絎�莊泣����������� 荀���障�������� perl -d scriptname ������������������ perl �����������㋘��莎桁����с����������������㋘� p ��� x ��勉�潟����潟����с����若�帥��罎���祉�с����障����� ��潟�若����勌賢�����������������⓾��b ��с����㋘�若�壔����ゃ�潟�����荐㊤�������� s ��� n ��с�鴻��������絎�茵����茵�������c ��у����������⓾��r ��泣����˨�若����潟����� ��祉����障����� ��������������������������˨�壔����ŝ����贋�������ʋ����純�с�����

�����<����������c��紊������勤Ě��鴻����鴻�������������������障����������������虁;��≪�� ��ŝ����c����������с����� ������紊�������絖⓾�吟�������勖�������勖�号����壔��荐�茯���̹�≪����⓾�����紊�������茯帥�鴻���������� ��ŝ�潟�í�ゃ�潟����˨�����茯㏍����������� perldoc ���篏帥��(�����������閩<�̹�蚊����鴻�� ������������ perldebug ��с��������)�����������������<�����絎�莊泣�с�����

SEE ALSO

perldebug, perldebguts, perldiag, perlrun

AUTHOR

Richard Foley <richard.foley@rfi.net> Copyright (c) 2000

CONTRIBUTORS

(莢∝�勤��)

罕������ŭ査��������������ʋ��罅����莢∝�勉�������⓾�������障�����; ��鴻��:

Ronald J Kimball <rjk@linguist.dartmouth.edu>

Hugo van der Sanden <hv@crypt0.demon.co.uk>

Peter Scott <Peter@PSDT.com>