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

 
Thursday, June 01, 2006

[Perl/펄] print 함수로, 비프음(Beep; 삑 하는 소리) 내기


#!/usr/bin/perl
use strict; use warnings;

print "\a";


위의 코드를 beep.pl 등의 이름으로 저장하고, 명령 프롬프트에서 실행하면, 삑 하는 비프음이 납니다.

위의 코드에서 필요한 부분은 사실상 print "\a"; 이것뿐입니다.


#!/usr/bin/perl
use strict; use warnings;

printf "\a";


위와 같이, print 가 아닌, printf 로도 같은 결과를 얻을 수 있습니다.




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>






관련 포스트:

[C언어] printf() 함수로, PC스피커에서, 비프음(Beep; 삑 하는 소리) 내기

배치 파일에서, PC스피커로, 비프음(Beep; 삑 하는 소리) 내기



더 읽기: Perl

0 Comments:

Post a Comment

<< Home RSS 2.0 feed

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