<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>

                      ŷ