<span id="7ztzv"></span>
<sub id="7ztzv"></sub>

<span id="7ztzv"></span><form id="7ztzv"></form>

<span id="7ztzv"></span>

        <address id="7ztzv"></address>


            ??????? Perl5??????/???

            ????????
            ???????????
            ?????????(\)??????
            ???????????
            ?]???????
            ??????????????
              ????????
            ??????????????
            ???????????????

            ????????
                ???t????????????????????????????????????????????Pascal??C?????????????????????????????????t?????????????????????????????????????q????Perl???????????????????????????????????????????????????????????
                Perl5??????????????????????????????????????????????????????????????????????????????????????????t??????????UNIX???????????????????????????????????
                Perl4????????????????????????????????????????????????????????????_main{}????????????Perl5?????????????????????????
                ??????????????????????????????Perl????????????????????????????????????????????????Perl????????????????????????Perl???ʦ???????????????????????????????
                ?????????????????????????????????????????????????????????????????????? ??Perl??????????????
            ???????????
                ???????????????$pointer???????????$pointer???????????????????????????????????
                ?ʦ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
                ????????????????
                ???$pointer???????????????????????@$pointer???????????????????@$pointer????????????$pointer????????????????????????%$pointer?????????????????????
                ?????????????????????????????????????????????????????????????????????--C?????????????--????Perl??????????????????????????R??????:)
                ???L??Perl???????????????????
            ?????????(\)??????
                ???????????C?????????????????&????????????????\??????????????????????????????????????????????
                $variavle = 22;
                $pointer = \$variable;
                $ice = "jello";
                $iceprt = \$ice;
                ????$pointer??????$variable??????????$iceptr???"jello"??????????????$variable?????????????????$pointer??????????????????????????????????$pointer??$variable????????????????
                ????????????????????$pointer?????$variable?????????????????????????????????$?????????
            #!/usr/bin/perl
            $value = 10;
            $pointer = \$value;
            printf "\n Pointer Address $pointer of $value \n";
            printf "\n What Pointer *($pointer) points to $$pointer\n";
                ??????????
            Pointer Address SCALAR(0x806c520) of 10
            What Pointer *(SCALAR(0x806c520)) points to 10
                ???????????????????????????????????$pointer???????????$$pointer????$variable?????
                ?????????????SCALAR???????????????SCALAR???????????????????????????????????????????????????
                ?????????????????????????????????????????????????????????????????????????????????????Perl????NULL??????????????????????????????????????????????????????????
            ???????????
                ????Perl??????????????????????????Perl??????????????????????????????????????????????????????????????????????????????????????????????????????????
                ??????????????????????????????????????????????????
            1  #!/usr/bin/perl
            2  #
            3  # Using Array references
            4  #
            5  $pointer = \@ARGV;
            6  printf "\n Pointer Address of ARGV = $pointer\n";
            7  $i = scalar(@$pointer);
            8  printf "\n Number of arguments : $i \n";
            9  $i = 0;
            10 foreach (@$pointer) {
            11   printf "$i : $$pointer[$i++]; \n";
            12 }
                ?????????
            $ test 1 2 3 4
            Pointer Address of ARGV = ARRAY(0x806c378)
            Number of arguments : 4
            0 : 1;
            1 : 2;
            2 : 3;
            3 : 4;     ??5??????$pointer???????@ARGV????6?????ARGV??????$pointer????????????????????????C???????????????????????7??????scalar()????????????????????????@ARGV????????????????@$pointer??????????????????$pointer?????????@??????????????????????????????????10?????7?????????11???????$$pointer[$i]??????????
                ???????????????????????????????--??????????????????????$poniter???????????????????????????????????????????--ARRAY??SCALAR??????????????????????????????HASH??CODE???????????????????????
            #!/usr/bin/perl
            1  #
            2  # Using Associative Array references
            3  #
            4  %month = (
            5   '01', 'Jan',
            6   '02', 'Feb',
            7   '03', 'Mar',
            8   '04', 'Apr',
            9   '05', 'May',
            10  '06', 'Jun',
            11  '07', 'Jul',
            12  '08', 'Aug',
            13  '09', 'Sep',
            14  '10', 'Oct',
            15  '11', 'Nov',
            16  '12', 'Dec',
            17  );
            18
            19 $pointer = \%month;
            20
            21 printf "\n Address of hash = $pointer\n ";
            22
            23 #
            24 # The following lines would be used to print out the
            25 # contents of the associative array if %month was used.
            26 #
            27 # foreach $i (sort keys %month) {
            28 # printf "\n $i $$pointer{$i} ";
            29 # }
            30
            31 #
            32 # The reference to the associative array via $pointer
            33 #
            34 foreach $i (sort keys %$pointer) {
            35   printf "$i is $$pointer{$i} \n";
            36 }
                ??????????
            $ mth
            Address of hash = HASH(0x806c52c)
            01 is Jan
            02 is Feb
            03 is Mar
            04 is Apr
            05 is May
            06 is Jun
            07 is Jul
            08 is Aug
            09 is Sep
            10 is Oct
            11 is Nov
            12 is Dec
                ????????????????????????????????$$pointer{$index}???????$index??????????????????????????????????????????????????????????=>?????????????????????????????????
            1  #!/usr/bin/perl
            2  #
            3  # Using Array references
            4  #
            5  %weekday = (
            6    '01' => 'Mon',
            7    '02' => 'Tue',
            8    '03' => 'Wed',
            9    '04' => 'Thu',
            10   '05' => 'Fri',
            11   '06' => 'Sat',
            12   '07' => 'Sun',
            13   );
            14 $pointer = \%weekday;
            15 $i = '05';
            16 printf "\n ================== start test ================= \n";
            17 #
            18 # These next two lines should show an output
            19 #
            20   printf '$$pointer{$i} is ';
            21   printf "$$pointer{$i} \n";
            22   printf '${$pointer}{$i} is ';
            23   printf "${$pointer}{$i} \n";
            24   printf '$pointer->{$i} is ';
            25
            26   printf "$pointer->{$i}\n";
            27 #
            28 # These next two lines should not show anything 29 #
            30   printf '${$pointer{$i}} is ';
            31   printf "${$pointer{$i}} \n";
            32   printf '${$pointer->{$i}} is ';
            33   printf "${$pointer->{$i}}";
            34 printf "\n ================== end of test ================= \n";
            35
                ??????????
            ================== start test =================
            $$pointer{$i} is Fri
            ${$pointer}{$i} is Fri
            $pointer->{$i} is Fri
            ${$pointer{$i}} is
            ${$pointer->{$i}} is
            ================== end of test =================
                ????????????????????????????????????????????????????????????????????????????????Perl???????????????print????????????????????????Perl??????????????????
            ?]???????
                ???@array = list;???????????????????????????????????????????????????????????????????????
                $line = ['solid' , 'black' , ['1','2','3'] , ['4','5','6']];
                ??????????????????????????????$line???????????????????????????????????????????????????????????????????????????????????????????????????
            $arrayReference->[$index]     single-dimensional array
            $arrayReference->[$index1][$index2]   two-dimensional array
            $arrayReference->[$index1][$index2][$index3] three-dimensional array
                ?????????????????????????????????????????????????????????????????????????????????????--????????????????????????????????????????????Perl????????????????????????????????????:)
                ?????????????????????????????????????????????????????
                ??????????????????????????
            1  #!/usr/bin/perl
            2  #
            3  # Using Multi-dimensional Array references
            4  #
            5  $line = ['solid', 'black', ['1','2','3'] , ['4', '5', '6']];
            6  print "\$line->[0] = $line->[0] \n";
            7  print "\$line->[1] = $line->[1] \n";
            8  print "\$line->[2][0] = $line->[2][0] \n";
            9  print "\$line->[2][1] = $line->[2][1] \n";
            10 print "\$line->[2][2] = $line->[2][2] \n";
            11 print "\$line->[3][0] = $line->[3][0] \n";
            12 print "\$line->[3][1] = $line->[3][1] \n";
            13 print "\$line->[3][2] = $line->[3][2] \n";
            14 print "\n"; # The obligatory output beautifier.
                ??????????
            $line->[0] = solid
            $line->[1] = black
            $line->[2][0] = 1
            $line->[2][1] = 2
            $line->[2][2] = 3
            $line->[3][0] = 4
            $line->[3][1] = 5
            $line->[3][2] = 6
                ??????????????????????????????????????
            1  #!/usr/bin/perl
            2  #
            3  # Using Multi-dimensional Array references again
            4  #
            5  $line = ['solid', 'black', ['1','2','3', ['4', '5', '6']]];
            6  print "\$line->[0] = $line->[0] \n";
            7  print "\$line->[1] = $line->[1] \n";
            8  print "\$line->[2][0] = $line->[2][0] \n";
            9  print "\$line->[2][1] = $line->[2][1] \n";
            10 print "\$line->[2][2] = $line->[2][2] \n";
            11 print "\$line->[2][3][0] = $line->[2][3][0] \n";
            12 print "\$line->[2][3][1] = $line->[2][3][1] \n";
            13 print "\$line->[2][3][2] = $line->[2][3][2] \n";
            14 print "\n";
                ??????????
            $line->[0] = solid
            $line->[1] = black
            $line->[2][0] = 1
            $line->[2][1] = 2
            $line->[2][2] = 3
            $line->[2][3][0] = 4
            $line->[2][3][1] = 5
            $line->[2][3][2] = 6
                ???????????????????$line->[2][3][0]????????C??????Array_pointer[2][3][0]???????????????????????????????n????????????????????????????????????????????
            1 #!/usr/bin/perl
            2 #
            3 # Using Multi-dimensional Array and Hash references
            4 #
            5 %cube = (
            6 '0', ['0', '0', '0'],
            7 '1', ['0', '0', '1'],
            8 '2', ['0', '1', '0'],
            9 '3', ['0', '1', '1'],
            10 '4', ['1', '0', '0'],
            11 '5', ['1', '0', '1'],
            12 '6', ['1', '1', '0'],
            13 '7', ['1', '1', '1']
            14 );
            15 $pointer = \%cube;
            16 print "\n Da Cube \n";
            17 foreach $i (sort keys %$pointer) {
            18 $list = $$pointer{$i};
            19 $x = $list->[0];
            20 $y = $list->[1];
            21 $z = $list->[2];
            22 printf " Point $i = $x,$y,$z \n";
            23 }
                ??????????
            Da Cube
            Point 0 = 0,0,0
            Point 1 = 0,0,1
            Point 2 = 0,1,0
            Point 3 = 0,1,1
            Point 4 = 1,0,0
            Point 5 = 1,0,1
            Point 6 = 1,1,0
            Point 7 = 1,1,1
                ???????????????????????%cube???????????????????????????????????????$list?????????????????$list = $$ pointer{$i}; ??????????????$x = $list->[0]; ... ?????????????$x??$y??$z?????($x,$y,$z) = @$list;
                ????????????????$????->???????????????????????????????
                $$names[0] = "kamran";
                $names->[0] = "kamran";
                ???????????????????????
                $$lastnames{"kamran"} = "Husain";
                $lastnames->{"kamran"} = "Husain";
                Perl?????????????????????????????????????????????????????????????????????????????????????????????????????????contours???????????????
                $contours[$x][$y][$z] = &xlate($mouseX, $mouseY);
            ??????????????
                perl??????????????C????????????????????????
                $pointer_to_sub = sub {... declaration of sub ...};
                ?????????????????????????????
                &$pointer_to_sub(parameters);
          1. ????????

          2.     ????????????????????????????????????????????????????????????????????????????????????????????????Perl??Closure??????????????Closure??????????????????????????????????????????(Closure???OOP?????)???????????????????????????????????????????????????????????^
            #!/usr/bin/perl
            sub errorMsg {
              my $lvl = shift;
              #
              # define the subroutine to run when called.
              #
              return sub {
                my $msg = shift; # Define the error type now.
                print "Err Level $lvl:$msg\n"; }; # print later.
              }
            $severe = errorMsg("Severe");
            $fatal = errorMsg("Fatal");
            $annoy = errorMsg("Annoying");

            &$severe("Divide by zero");
            &$fatal("Did you forget to use a semi-colon?");
            &$annoy("Uninitialized variable in use");
                ??????????
            Err Level Severe:Divide by zero
            Err Level Fatal:Did you forget to use a semi-colon?
            Err Level Annoying:Uninitialized variable in use
                ???????????errorMsg???????????$lvl???????????????????errorMsg?????????$lvl????????????????????????????????my???????????????????????????$lvl?????????errorMsg???????$lvl?????????????????????????????????????????????????????y??????$msg??????I????$lvl??????????????????????????
                ????????????????????????????Perl???????????
            ??????????????
                ????????????????????????????????????????????????????????@_???????????????????@_???????????????????????????????????????????@_??????????my(@a,@b)=@_; ??????????????????????????????@a????@b??????????????????????????????????????????????????????
            #!/usr/bin/perl
            @names = (mickey, goofy, daffy );
            @phones = (5551234, 5554321, 666 );
            $i = 0;
            sub listem {
              my ($a,$b) = @_;
              foreach (@$a) {
                print "a[$i] = " . @$a[$i] . " " . "\tb[$i] = " . @$b[$i] ."\n";
                $i++;
              }
            }
            &listem(\@names, \@phones);
                ??????????
            a[0] = mickey     b[0] = 5551234
            a[1] = goofy      b[1] = 5554321
            a[2] = daffy      b[2] = 666
            
            ???
            1????????????????????????????????????????????
            2???????????????????????? (@variable)=@_; ????????????????????????????????????????????
            ???????????????
                ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
                spitOut(\*STDIN);
                spitOut(\*LPHANDLE);
                spitOut(\*LOGHANDLE);
                ?????????spitOut?????????
            sub spitOut {
              my $fh = shift;
              print $fh "Gee Wilbur, I like this lettuce\n";
            }
                ?????????????????????\*FILEHANDLE??

            ????? ????? ??


            paper | appdir | ssv
            <span id="7ztzv"></span>
            <sub id="7ztzv"></sub>

            <span id="7ztzv"></span><form id="7ztzv"></form>

            <span id="7ztzv"></span>

                  <address id="7ztzv"></address>

                      ŷ