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

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

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

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


            ????? ????????/?????

            ????????????????
            ????????
            ???????????????????
            ??????????
            ?‰]????????????
            ??????????????????????????
            ??????????
            ????§Ô?????????????
            ????¨´??????????
            ????¨´??????ø’???????
              1??(??)????
              2????
              3????

            ????????????????
                ????äû??????????§µ?????????¡À???????§Ö????????íà??????????????@array???????????
                $scalar = $array[2];
                ????????????????????????????????????????????????????????????????????§Õ???????????????????????§Õ???????????????????????????????????????????¡ê?
            1 : #!/usr/local/bin/perl
            2 :
            3 : while ($inputline = <STDIN>) {
            4 :   while ($inputline =~ /\b[A-Z]\S+/g) {
            5 :     $word = $&;
            6 :     $word =~ s/[;.,:-]$//; # remove punctuation
            7 :     for ($count = 1; $count <= @wordlist;
            8 :         $count++) {
            9 :       $found = 0;
            10:       if ($wordlist[$count-1] eq $word) {
            11:         $found = 1;
            12:         $wordcount[$count-1] += 1;
            13:         last;
            14:       }
            15:     }
            16:     if ($found == 0) {
            17:       $oldlength = @wordlist;
            18:       $wordlist[$oldlength] = $word;
            19:       $wordcount[$oldlength] = 1;
            20:     }
            21:   }
            22: }
            23: print ("Capitalized words and number of occurrences:\n");
            24: for ($count = 1; $count <= @wordlist; $count++) {
            25:   print ("$wordlist[$count-1]: $wordcount[$count-1]\n");
            26: }
                ???§ß?????¡ê?
            Here is a line of Input.
            This Input contains some Capitalized words.
            ^D
            Capitalized words and number of occurrences:
            Here: 1
            Input: 2
            This: 1
            Capitalized: 1
                ?????????¦Ä???????????????????????????????????????????????§Õ??????????????????¦²???????????$word????????????????????????????????????7~15??????@wordlist?§Ñ???????????ï…???????????$word????@wordcount???????????????????????????§Ô????????@wordlist??????????$word????16~20?§Ú?@wordlist??@wordcount?????????????
            ????????
                ???????????????????????????????§»?????????@wordlist????????????????????????????????????????????¦Ì??????????????????§Ò?????????????????????????????§Ò??y?????????????????
                ??§»?????????????????????????????¡À??????????????????Perl??????????????ï…??????????????????????????????????????????????ï…??§Û?????
                ?????????????????????????????????Perl???%???????????????????????@??????????????????????%????????????????????????????????????????????????
            ???????????????????
                ??????????¡À??????¦Ê¦Ì?/????????????????????$?????????¡À????????¦¶?????????»Ç
            $fruit{"bananas"}
            $number{3.14159}
            $integer{-7}
                ?????????????¡À??»Ç
                $fruit{$my_fruit}
            ??????????
                ?????????????????????????????????????$fruit{"bananas"} = 1?? ??1????????????%fruit?¡À??bananas???????????????????????????????????%fruit??¦Ä??¨´????????????
                ?????????¨´??????????????????????????????¨´????????§Õ????????????????????????????????
            1 : #!/usr/local/bin/perl
            2 :
            3 : while ($inputline = ) {
            4 :   while ($inputline =~ /\b[A-Z]\S+/g) {
            5 :     $word = $&;
            6 :     $word =~ s/[;.,:-]$//; # remove punctuation
            7 :     $wordlist{$word} += 1;
            8 :   }
            9 : }
            10: print ("Capitalized words and number of occurrences:\n");
            11: foreach $capword (keys(%wordlist)) {
            12:   print ("$capword: $wordlist{$capword}\n");
            13: }
                ???§ß?????¡ê?
            Here is a line of Input.
            This Input contains some Capitalized words.
            ^D
            Capitalized words and number of occurrences:
            This: 1
            Input: 2
            Here: 1
            Capitalized: 1
                ????????????¦Ã???????????????????????????????20?§Þ??????7?§³?
                ???????¨´???????%wordlist???????????§Õ???????¡À????????????????????????????????11??????????????keys()??????????????????????¡À??§Ò??foreach????????§Ò??????
                ?????????????????????????????????keys()???????????????????????????¦Ê????????????????????????????????????????????
                ?????????????????????????????sort()??????keys()????????????§µ??»Ç
            foreach $capword (sort keys(%wordlist)) {
              print ("$capword: $wordlist{$capword}\n");
            }
            ?‰]????????????
                ????????????????????????ï…?»Ç
                %fruit = ("apples",17,"bananas",9,"oranges","none");
                ???????????????üA??????????????
          1. ?¡À??apples????????17
          2. ?¡À??bananas????????9
          3. ?¡À??oranges????????none
          4.     ??????§Ò?????????øx????Perl5???????"=>"??","??????¡À????????"=>"????????§»??????????§¹???
                %fruit = ("apples"=>17,"bananas"=>9,"oranges"=>"none");
            ??????????????????????????
                ???§Ò????????????????????????????????ï…???????????????????????»Ç
                @fruit = ("apples",17,"bananas",9,"oranges","none");
                %fruit = @fruit;
                ????????????????øx????????????»Ç
                %fruit = ("grapes",11,"lemons",27);
                @fruit = %fruit;
                ????????????????¦Ä???ÈÉ??????????@fruit?????("grapes",11,"lemons",27)??("lemons",27,"grapes",11)??
                ?????????????????????????»Ç%fruit2 = %fruit1; ?????????????????????§»?????????????????????????»Ç
                ($var1, $var2, %myarray) = @list;
                ??????@list????????????$var1???????????$var2??????????%myarray??
                ????????????????????????§Ò?????????????????????????????????????§Ñ?split()??????????--????§Ò?--????????????????????
            1: #!/usr/local/bin/perl
            2:
            3: $inputline = <STDIN>;
            4: $inputline =~ s/^\s+|\s+\n$//g;
            5: %fruit = split(/\s+/, $inputline);
            6: print ("Number of bananas: $fruit{\"bananas\"}\n");
                ???§ß?????¡ê?
            oranges 5 apples 7 bananas 11 cherries 6
            Number of bananas: 11
            ??????????
                ????????????????????????????¦Ä?????????????????????????????????????$fruit{"lime"} = 1;?????¡À??lime????1????????
                ?????????????????????delete???????????????????
                delete ($fruit{"lime"});
            ???
            1?????????delete??????????????????????????¦·????????
            2???????????????????????????push??pop??shift??splice??????????¦Ë??????????
            ????§Ô?????????????
                ???????????keys()????????????????¡À???§Ò???»Ç
            %fruit = ("apples", 9,
                      "bananas", 23,
                      "cherries", 11);
            @fruitsubs = keys(%fruits);
            
                ????@fruitsubs??????apples??bananas??cherries??????§Ò???????????????§Ò???§Õ????????????????§µ??????sort()??????
                @fruitindexes = sort keys(%fruits);
                ????????("apples","bananas","cherries")???????????????values()???????????????§Ò???»Ç
            %fruit = ("apples", 9,
                       "bananas", 23,
                       "cherries", 11);
            @fruitvalues = values(%fruits);
            
                ????@fruitvalues????????(9,23.11)?????????????
            ????¨´??????????
                ???????????????keys()??????foreach?????????????§¹??????????????????¡À?????????????????»Ç
            foreach $holder (keys(%records)){
              $record = $records{$holder};
            }
                Perl????????§¹????????????????????each()???»Ç
            %records = ("Maris", 61, "Aaron", 755, "Young", 511);
            while (($holder, $record) = each(%records)) {
              # stuff goes here
            }
                each()??????¦Ç????????????§Ò?????????????¡À?????????????????????????????§Ò??
                ?????????each()????????????????????????????????????
            ????¨´??????ø’???????
                ?¨´???????????????????????????§Ô?????????????????????????????????????????????
            1??(??)????
                ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
                ??Perl?§µ???????????¨´????????????????????????????????????????????????????????????§Ö?????????
            %words = ("abel", "baker", 
                      "baker", "charlie",
                      "charlie", "delta",
                      "delta", "");
            $header = "abel";
            
                ?????§µ???????$header?????????§Ö????????????????????????????????¡À????baker??????????????¡À??????????
                ?¡À??delta????????????????????????????????
                ????????????????¦Ä?????????????§Ø???????????¡ê???????????¨¢?????????????????????????????§Ö?????
            1 : #!/usr/local/bin/perl
            2 :
            3 : # initialize list to empty
            4 : $header = "";
            5 : while ($line = <STDIN>) {
            6 :   # remove leading and trailing spaces
            7 :   $line =~ s/^\s+|\s+$//g;
            8 :   @words = split(/\s+/, $line);
            9 :   foreach $word (@words) {
            10:     # remove closing punctuation, if any
            11:     $word =~ s/[.,;:-]$//;
            12:     # convert all words to lower case
            13:     $word =~ tr/A-Z/a-z/;
            14:     &add_word_to_list($word);
            15:   }
            16: }
            17: &print_list;
            18:
            19: sub add_word_to_list {
            20:   local($word) = @_;
            21:   local($pointer);
            22:
            23:   # if list is empty, add first item
            24:   if ($header eq "") {
            25:     $header = $word;
            26:     $wordlist{$word} = "";
            27:     return;
            28:   }
            29:   # if word identical to first element in list,
            30:   # do nothing
            31:   return if ($header eq $word);
            32:   # see whether word should be the new
            33:   # first word in the list
            34:   if ($header gt $word) {
            35:     $wordlist{$word} = $header;
            36:     $header = $word;
            37:     return;
            38:   }
            39:   # find place where word belongs
            40:   $pointer = $header;
            41:   while ($wordlist{$pointer} ne "" &&
            42:     $wordlist{$pointer} lt $word) {
            43:     $pointer = $wordlist{$pointer};
            44:   }
            45:   # if word already seen, do nothing
            46:   return if ($word eq $wordlist{$pointer});
            47:   $wordlist{$word} = $wordlist{$pointer};
            48:   $wordlist{$pointer} = $word;
            49: }
            50:
            51: sub print_list {
            52:   local ($pointer);
            53:   print ("Words in this file:\n");
            54:   $pointer = $header;
            55:   while ($pointer ne "") {
            56:     print ("$pointer\n");
            57:     $pointer = $wordlist{$pointer};
            58:   }
            59: }
                ???§ß?????¡ê?
            Here are some words.
            Here are more words.
            Here are still more words.
            ^D
            Words in this file:
            are
            here
            more
            some
            still
            words
                ????????????????
          5. ???????????????????????????
          6. ?????add_word_to_list?????????????????
          7. ?????print_list?????????????
          8.     ??3~17???????????4?§Ô??????????????????$header??????????5??????????¦Æ???????????7????????¦Â??????8?§ß????????????9~15?§Ö????????¦Ä?????????????????????????????????????????????13?§Ñ??????????§³§Õ???????14?§Õ?????????add_word_to_list??
                ?????add_word_to_list?????24?§Õ???????????????????????25?§ß????????$header??26?§Õ????????????????????????????%wordlist?§³???????????37?§Þ?????????????????????????????????????????????????????¦Ì????????????????????????????????????$header???????????????
                1????????????????¡À?????¦Ì???????????????????
                2?????¦Ì??????$header??
                ??????¦Ì??????????????????40~44?????t??????$pointer???????????§¹¦Ë???41~44???????$wordlist{$pointer}????????$word??????????46?§Ó??????????????????§µ???????????????47~48?§ß????????????§³?????47?§Õ????????$wordlist{$word}??????$wordlist{$pointer}?????$wordlist{$word}??$wordlist{$pointer}???????????????48?§ß?$wordlist{$pointer}??????$word??????$wordlist{$pointer}??????????????$wordlist{$word}??
                ????????????????print_list()???????????????????$pointer????????????????$wordlist{$pointer}???????????????
                ?????????????????????§»????????sort()??keys()??????????????????????»Ç
            foreach $word (sort keys(%wordlist)) {
              # print the sorted list, or whatever }
                ??????????�p?????????????????????§Ü??????‰^
            2????
                ????????????????(structure)???????????????????§Ö???????????????????????????????????????
                Perl???????????????????????????¨´???????????????????C?????????¦Ì????
            struce{
              int field1;
              int field2;
              int field3; }mystructvar;
                ???????????????????????????????????ï…?¡À????field1??field2??field3???»Ç
            %mystructvar = ("field1" , "" ,
                  "field2" , "" ,
                  "field3" , "" ,);
                ??????C????????????????????????%mystrctvar???????????¡À????field1??field2??field3??????????????????????????????????????¡À??????§µ??»Ç
                $mystructvar{"field1"} = 17;
            3????
                ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
                ??????????????????????????????????????????????????????????????
                ????????????????????
          9. ?????????????????????????/????????????/?????????????????/??????
          10. ?????????????¦Ê¦Í????????????????????
          11. ??§Ü??????????????????
          12.     ?§Ø?????¨´?????????????????????????????????????????????left??right???????????íàalphaleft??alpharight???alpha?????????????????????????????????????????????
            1 : #!/usr/local/bin/perl
            2 :
            3 : $rootname = "parent";
            4 : %tree = ("parentleft", "child1",
            5 :          "parentright", "child2",
            6 :          "child1left", "grandchild1",
            7 :          "child1right", "grandchild2",
            8 :          "child2left", "grandchild3",
            9 :          "child2right", "grandchild4");
            10: # traverse tree, printing its elements
            11: &print_tree($rootname);
            12:
            13: sub print_tree {
            14:   local ($nodename) = @_;
            15:   local ($leftchildname, $rightchildname);
            16:
            17:   $leftchildname = $nodename . "left";
            18:   $rightchildname = $nodename . "right";
            19:   if ($tree{$leftchildname} ne "") {
            20:     &print_tree($tree{$leftchildname});
            21:   }
            22:   print ("$nodename\n");
            23:   if ($tree{$rightchildname} ne "") {
            24:     &print_tree($tree{$rightchildname});
            25:   }
            26: }
                ?????????¡ê?
            grandchild1
            child1
            grandchild2
            parent
            grandchild3
            child2
            grandchild4
                ?¨®???????????????????

                ?????print_tree()????????????????????????????????????????????????????????????????????????22?????19????????????????????????????????????????????????????????????22?????25?§Ü????????????????????????????????????????????
                ????????????????????????????????¡À?????????????????????????????

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


            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>

                      ÑÇÖÞÅ·ÃÀÔÚÏß