mwultong Blog ... 프로그래밍 / 계산기

컴퓨터 엑셀 워드 포토샵 구글어스 WINDOWS JAVASCRIPT JAVA C++

 
Monday, August 07, 2006

Perl/펄] 각 내장 함수의 사용법 보기 / 함수 레퍼런스(Reference) 보기 - perldoc


시스템에 펄을 설치하면 perldoc 이라는 명령어를 쓸 수 있습니다. 펄 문서를 보여주는 명령인데, 내장 함수 (Builtin Function) 의 레퍼런스(Reference) 즉 사용법 설명서를 보여 주는 기능도 있습니다.

perldoc 뒤에 -f 라는 옵션을 붙인 후, 알고 싶은 함수명을 붙여 줍니다.

가령 print 함수에 대해 알고 싶다면

perldoc -f print

이렇게 합니다.


결과는 다음과 같습니다:
D:\Z>perldoc -f print
    print FILEHANDLE LIST
    print LIST
    print   Prints a string or a list of strings. Returns true if
            successful. FILEHANDLE may be a scalar variable name, in which
            case the variable contains the name of or a reference to the
            filehandle, thus introducing one level of indirection. (NOTE: If
            FILEHANDLE is a variable and the next token is a term, it may be
            misinterpreted as an operator unless you interpose a "+" or put
            parentheses around the arguments.) If FILEHANDLE is omitted,
            prints by default to standard output (or to the last selected
            output channel--see "select"). If LIST is also omitted, prints
            $_ to the currently selected output channel. To set the default
            output channel to something other than STDOUT use the select
            operation. The current value of $, (if any) is printed between
            each LIST item. The current value of $\ (if any) is printed
            after the entire LIST has been printed. Because print takes a
            LIST, anything in the LIST is evaluated in list context, and any
            subroutine that you call will have one or more of its
            expressions evaluated in list context. Also be careful not to
            follow the print keyword with a left parenthesis unless you want
            the corresponding right parenthesis to terminate the arguments
            to the print--interpose a "+" or put parentheses around all the
            arguments.

            Note that if you're storing FILEHANDLEs in an array, or if
            you're using any other expression more complex than a scalar
            variable to retrieve it, you will have to use a block returning
            the filehandle value instead:

                print { $files[$i] } "stuff\n";
                print { $OK ? STDOUT : STDERR } "stuff\n";


D:\Z>perldoc -f rand
    rand EXPR
    rand    Returns a random fractional number greater than or equal to 0
            and less than the value of EXPR. (EXPR should be positive.) If
            EXPR is omitted, the value 1 is used. Currently EXPR with the
            value 0 is also special-cased as 1 - this has not been
            documented before perl 5.8.0 and is subject to change in future
            versions of perl. Automatically calls "srand" unless "srand" has
            already been called. See also "srand".

            Apply "int()" to the value returned by "rand()" if you want
            random integers instead of random fractional numbers. For
            example,

                int(rand(10))

            returns a random integer between 0 and 9, inclusive.

            (Note: If your rand function consistently returns numbers that
            are too large or too small, then your version of Perl was
            probably compiled with the wrong number of RANDBITS.)


D:\Z>





tag: perl
Perl | 펄

0 Comments:

<< Home RSS 2.0 feed

구글 Google 에서 제공하는 무료 블로그 서비스인 블로거 Blogger 의 인터넷 주소는 www.blogger.com 입니다. Blogger 에 블로그를 만들면, blogspot.com 이라는 주소에 블로그가 생성됩니다.
블로그를 직접 방문하지 않고도 최신 게시물을 구독하려면 RSS 2.0 feed 주소를 리더기에 등록하시면 됩니다.
Previous Posts
Monthly Archives
Top