<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

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

    ????????????
    ?????????????
    ?????????????????
      1???????????
      2?????????????
      3??????????
      4???????????
    ???????????????
    ?]???
    ????????????????
    ?????printf????????

        ?????????????print????????????????????????????????????????????write????????????????????????
    ?????????????
        ???????????????????
         1??????????$~????????????
         2????????write
        ???
    1 : #!/usr/local/bin/perl
    2 :
    3 : $~ = "MYFORMAT";
    4 : write;
    5 :
    6 : format MYFORMAT =
    7 : ===================================
    8 : Here is the text I want to display.
    9 : ===================================
    10: .
        ??????????
    $ program
    ===================================
    Here is the text I want to display.
    ===================================
    $
        ???????$~???????????Perl???????????????????????????????????????????????????????MYFORMAT????Perl???????????????STDOUT?????????
    ?????????????????
        ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????write?????????????????????????????
    1???????????
        ???????????????????????????????????
    format MYFORMAT =
    ==========================================================
    The winning number is @<<<<<<!
    $winnum
    ==========================================================
    .
        ??????write???????????????????????????$winnum???????????????????????????????????????????STDIN???????????????????????????????????????????
    1 : #!/usr/local/bin/perl
    2 :
    3 : while ($line = ) {
    4 :   $line =~ tr/A-Z/a-z/;
    5 :   $line =~ s/[^a-z]//g;
    6 :   @letters = split(//, $line);
    7 :   foreach $letter (@letters) {
    8 :     $lettercount{$letter} += 1;
    9 :   }
    10: }
    11:
    12: $~ = "WRITEHEADER";
    13: write;
    14: $count = 0;
    15: foreach $letter (reverse sort occurrences
    16:       (keys(%lettercount))) {
    17:   &write_letter($letter, $lettercount{$letter});
    18:   last if (++$count == 5);
    19: }
    20:
    21: sub occurrences {
    22:   $lettercount{$a} <=> $lettercount{$b};
    23: }
    24: sub write_letter {
    25:   local($letter, $value) = @_;
    26:
    27:   $~ = "WRITELETTER";
    28:   write;
    29: }
    30: format WRITEHEADER =
    31: The five most frequently occurring letters are:
    32: .
    33: format WRITELETTER =
    34:   @: @<<<<<<
    35:   $letter, $value
    36: .
        ?????????
    $ program
    This is a test file.
    This test file contains some input.
    The quick brown fox jumped over the lazy dog.
    ^D
    The five most frequently occurring letters are:
            t: 10
            e: 9
            i: 8
            s: 7
            o: 6
    $
    
    2?????????????
        ????????????????????????write_letter????write??????????????????????????????????????????????????????17??????????????????????????????????????????????t??????$letter??$value?????????????foreach????????????????????????
        ??????????????my???????????????????????????????????????????????????write?????????????????local???^??local??my?????????????
        ???Perl4?????my?????????????????
    3??????????
        ???????????????????write????????????????????????????????????

    ??? ?????
    @<<< ????????
    @>>> ????????
    @||| ???????
    @##.##   ???????????  
    @* ???????

        ?????????????????????????????@????????????????????????????????????????
        ?????????????????@*???????????????????????@?????????????????
         @###.##
        ?????????????????????????????????
    4???????????
        ?????????????????@????????????????????????????????????
    format SPECIAL =
    This line contains the special character @.
    "@"
    .
    ???????????????
        ?????????write???????????????????STDOUT???????????????????????????????????????????????????????????????????????write???
         write (MYFILE);
        ??????write???????????MYFILE???????????????MYFILE?????????????????$~????????????????????????????$~??????????????????????????????????????????$~???????write?????
         select (MYFILE);
         $~ = "MYFORMAT";
         write;
        ??select???????????????????????????????????????????????????????????????????????????????????????????????????
    sub write_to_stdout {
      local ($savefile, $saveformat);
      $savefile = select(STDOUT);
      $saveformat = $~;
      $~ = "MYFORMAT";
      write;
      $~ = $saveformat;
      select($savefile);
    }
    ?]???
        ?????????????????????????????????????????????????????????????????????????????filename_TOP????????????????????????????????
         format STDOUT_TOP =
         Consolidated Widgets Inc. 1994 Annual Report
         .
        ?????????????????????????????????????????????????????????$%???
         format STDOUT_TOP =
         Page @<<.
         $%
         .
        ?????????????????????$^???????????????????$~?????$^?????????????????????????select??????????
        ??????????????60????????????$=???????????
         $= = 66; #??????66??
        ???????????????????write??????
        ???????????????????print?????????????write??????Perl?????????????????????????????print?????????????????????????????$-??$-?????????????????????????$-??????????????????????????
         print ("Here is a line of output\n");
         $- -= 1;
    ????????????????
        ?????????????@*????????????????????????????????????????????????????Perl????????????????????????????????????????????@???????^?????????????????????Perl??????????????t?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????~?????????????
    1 : #!/usr/local/bin/perl
    2 :
    3 : @quotation = <STDIN>;
    4 : $quotation = join("", @quotation);
    5 : $~ = "QUOTATION";
    6 : write;
    7 :
    8 : format QUOTATION =
    9 : Quotation for the day:
    10: -----------------------------
    11: ~  ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    12: $quotation
    13: ~  ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    14: $quotation
    15: ~  ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    16: $quotation
    17: -----------------------------
    18: .
        ?????????
    $ program
    Any sufficiently advanced programming
    language is indistinguishable from magic.
    ^D
    Quotation for the day:
    -----------------------------
       Any sufficiently advanced programming language is
       indistinguishable from magic.
    -----------------------------
    $
        ?????????????????~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????~?????????????????????????????????????????????????????????
    1 : #!/usr/local/bin/perl
    2 :
    3 : @quotation = <STDIN>;
    4 : $quotation = join("", @quotation);
    5 : $~ = "QUOTATION";
    6 : write;
    7 :
    8 : format QUOTATION =
    9 : Quotation for the day:
    10: -----------------------------
    11: ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    12: $quotation
    13: -----------------------------
    14: .
        ??????????????
    ?????printf????????
        ??????????????????????????????????????printf??????C??????printf??????????????printf?????????????????????????????????????????????????????????????????????????????I???
         printf("The number I want to print is %d.\n", $number);
        ???????????????

    ???   ????
    %c ???????
    %d ?????????
    %e ???????????????????  
    %f ??????????????????
    %g ?????????????
    %o ?????????
    %s ?????
    %u ?????????
    %x ???????????

        ???????????
    1??????d??o??u??x???????????????????????l?????????????????%ld??
    2??%????????????????????????????????????????????????????????????????????????????0?????????????0????%?????????????????????????
    3???????????(%c??%f??%g)????????????????????%8.3f????????8??????????????????????3??????????????????????????
    4????????????????????????????????????????n.m??????????n????????????m??????????????????????????????????????n-m?????

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

    paper | appdir | ssv 97av