'펄'에 해당되는 글 5건

  1. 2009.07.27 [PERL] HTML 메일 발송 테스트
  2. 2009.07.22 [PERL] 메일 발송 테스트
  3. 2009.01.15 [펌]Perl OOP
  4. 2009.01.14 [bookmark] perl function reference...
  5. 2009.01.14 perl multi comment 사용하기.

[PERL] HTML 메일 발송 테스트

ITWeb/개발일반 2009. 7. 27. 15:01

아래 글에 이어서.. 추가 입니다.

참고 URL :
http://alma.ch/perl/Mail-Sendmail-FAQ.html
http://search.cpan.org/~mivkovic/Mail-Sendmail-0.79/Sendmail.pm

sub setSendMail {
    my $message = $_[0];

    %mail = (
                To           => 'to@email.com',
                From         => 'from@email.com',
                Subject      => 'TITLE',
                'Content-type'  => 'text/html; charset="UTF-8"',
                Message      => "<span style='font-size:11px; font-family:맑은 고딕, 돋움'>$message</span>"
            );

    if ( $message ) {
        sendmail(%mail) or die $Mail::Sendmail::error;
        print "OK. Log says:\n", $Mail::Sendmail::log;
    }
}

보시는 바와 같이 빨간 부분을 추가해 주시면 됩니다.
Content-type 앞뒤로 quotation 빼먹으시면 정상적으로 적용 안되니 유의 하세요.

:

[PERL] 메일 발송 테스트

ITWeb/개발일반 2009. 7. 22. 16:41


우선 기본적으루다.. sendmail 을 이용해서 발송 해야 하는 건 아시죠..
리눅스 기반 입니다.

일단 sendmail 이 실행 되어 있어야 겠죠.
http://www.faqs.org/docs/linux_network/x15649.html

Perl 용 sendmail 모듈을 설치 하시죠.
http://search.cpan.org/~mivkovic/Mail-Sendmail-0.79/
http://search.cpan.org/~mivkovic/Mail-Sendmail-0.79_16/Sendmail.pm
저는 매뉴얼 설치 했습니다.
별거 없죠... 기냥.. 소스 받아서 압축 풀고 /usr/sbin/perl/site_perl 에 가져다 놓으면 끝..

샘플 코드 위에 링크 보면 있죠.. ㅋ
아래 코드는 구글링 해보시면 가장 많이 나오는 예제 중 하나 입니다.
두 가지를 다 넣어서 테스트 해본 거죠..

sub setSendMail {
    my $sendmailer = '/usr/sbin/sendmail';

    %mail = (
                To          => 'your@email.com',
                From        => 'your@email.com',
                Subject     => '제목 입력',
                Message     => "메시지 입력"
            );

    sendmail(%mail) or die $Mail::Sendmail::error;

    print "OK. Log says:\n", $Mail::Sendmail::log;

    open (MAIL, "|$sendmailer -oi -t");
    print MAIL "From: your@email.com\n";
    print MAIL "To: your@email.com\n";
    print MAIL "Subject: 제목입력\n\n";
    print MAIL "메시지 입력\n";
    close(MAIL);
}

그럼 즐프 하세요.

:

[펌]Perl OOP

ITWeb/개발일반 2009. 1. 15. 19:27

급해서.. 스크랩 부터.. ^^;

원본문서 : http://www.bjnet.edu.cn/tech/book/perl/ch19.htm

Chapter 19

Object-Oriented Programming in Perl

by Kamran Husain


CONTENTS
Listing 19.1. The initial Cocoa.pm package. package Cocoa;
sub new {

    my $this = {};  # Create an anonymous hash, and #self points to it.

    bless $this;       # Connect the hash to the package Cocoa.

    return $this;     # Return the reference to the hash.

    }



1;
Listing 19.2. Creating the constructor.
1  #!/usr/bin/perl

2  push (@INC,'pwd');

3  use Cocoa;

4  $cup = new Cocoa;
sub new {

        my $class = shift;        # Get the request class name

        my $this = {};

        bless $this, $class        # Use class name to bless() reference

        $this->doInitialization();

        return $this;

    }

 

더 자세한 건 사이트 들어가서 보삼.. ㅎㅎ

perl 로 class 만드는 것 중 기본은.. package 를 만드는 것이고 pacakge 의 끝은 1; 로 끝나야 한다는거.. ㅎㅎ

:

[bookmark] perl function reference...

ITWeb/개발일반 2009. 1. 14. 16:44

http://perldoc.perl.org/index-functions.html
근데 뭐.. 기냥..
http://perldoc.perl.org 들어 가서 찾아 보면.. 다 있으니.. 알아서 하세요.. :)
:

perl multi comment 사용하기.

ITWeb/개발일반 2009. 1. 14. 10:48

참조문서 : http://perldoc.perl.org/perlpod.html

일반적으로 line comment 는 # 으로 사용한다.
그럼 multi-line comment 는 어케 할까?

문서를 찾아 보니.. 이와 같이 하는군요..

=pod
commenting....
commenting....
commenting....
.....
=cut

관련 상세 내용은 위에 문서 링크 보시면 됩니다.. ^^*

: