다시한번 부탁 드려요 이 소스좀 분석해 주세요 (perl)

익명 사용자의 이미지

perl로 작성된 소스 입니다
제가 해석한 부분이 맞는지 봐주시고 모르는 부분좀 해석좀 해주세요
opendir ( DIR , "$CERTS_DIR" );
###DIR=$CERTS_DIR이렇게 해석하면 되나요?
@certs = grep(/pem/, readdir( DIR ) );
###DIR디렉토리를 읽어 pem파일이 있는지 확인하고 배열변수certs에 넣음
closedir( DIR );
#닫음
foreach $file ( @certs ) {
#certs의 모든 요소를 file에 활당(대입)하고 다 활당하면 닫음
print "Adding certificate ";

$info = `$SSL_DIR/bin/openssl x509 -text -noout <$CERTS_DIR/$file`;
###file안에 있는 파일을 ` `안에 있는 시스템 명령어를 실행
_______________________아래 부터는 이해가 가지 않아요____________
next if ( $info =~ /error/i );
##(질문)"=~ /error/i"이것이 폴더를 의미 하나요?

( $serial ) =
( $info =~ /Serial Number[^x]*.([^\)]+)/i );
##(질문)"=~ /Serial Number[^x]*.([^\)]+)/i"이건 어떻게 해석을?
( $notBefore ) =
( $info =~ /Not Before ([^\n]+)/i );

( $notAfter ) =
( $info =~ /Not after ([^\n]+)/i );

if ( length( $serial ) < 2 ) {
$serial = "0" . uc($serial);
##(질문)"$serial = "0" . uc($serial);"이건 또 어떻게?
}

print " ( $serial )\n";
print " Not Before $notBefore\n";
print " Not After $notAfter\n";

$fileName = "$CERTS_DIR/$file";
$cert = "";
open( FD, "$fileName" ) or die "Can't access $fileName\n\n";
while( $tmp = ) {
next if ( ($cert eq "") and ($tmp !~ /BEGIN CERTIFICATE/ ));
$cert .= $tmp;
}
close( FD );
_____________________________________________________________________
__________________________________
제가 perl를 어제부터 시작해서 기초도 없어요

익명 사용자의 이미지

김혜림 wrote..
perl로 작성된 소스 입니다
제가 해석한 부분이 맞는지 봐주시고 모르는 부분좀 해석좀 해주세요
opendir ( DIR , "$CERTS_DIR" );
###DIR=$CERTS_DIR이렇게 해석하면 되나요?

opendir 은 디렉토리 핸들을 여는 함수 입니다.
그러니까 DIR 은 디렉토리 핸들이라고 할 수 있죠.
나중에 readdir 로 읽어들일 수 있습니다.

@certs = grep(/pem/, readdir( DIR ) );
###DIR디렉토리를 읽어 pem파일이 있는지 확인하고 배열변수certs에 넣 음

pem이 있는 줄을 @certs 에 넣는것입니다....

closedir( DIR );
#닫음
foreach $file ( @certs ) {
#certs의 모든 요소를 file에 활당(대입)하고 다 활당하면 닫음
print "Adding certificate ";

각줄마다 $file 로 대입하면서..배열끝까지 루프를 도는겁니다..


$info = `$SSL_DIR/bin/openssl x509 -text -noout <$CERTS_DIR/ $file`;
###file안에 있는 파일을 ` `안에 있는 시스템 명령어를 실행
_______________________아래 부터는 이해가 가지 않아요____________
next if ( $info =~ /error/i );
##(질문)"=~ /error/i"이것이 폴더를 의미 하나요?

$info 에 error 가 있다면... 처음 for 문으로 되돌아 갑니다.


( $serial ) =
( $info =~ /Serial Number[^x]*.([^\)]+)/i );
##(질문)"=~ /Serial Number[^x]*.([^\)]+)/i"이건 어떻게 해석을?

해당 reg-expression을 찾아서 ([^\)]+)에 해당하는 데이타를 $serial 에
대입하라는겁니다.

( $notBefore ) =
( $info =~ /Not Before ([^\n]+)/i );

( $notAfter ) =
( $info =~ /Not after ([^\n]+)/i );

이것도 마찬가지죠...^^

if ( length( $serial ) < 2 ) {
$serial = "0" . uc($serial);
##(질문)"$serial = "0" . uc($serial);"이건 또 어떻게?
}

시리얼이 2자리보다 작다면... 앞에 0을 붙이라는 얘기입니다.uc 는 잘 모
르겠네요..~~~

print " ( $serial )\n";
print " Not Before $notBefore\n";
print " Not After $notAfter\n";

$fileName = "$CERTS_DIR/$file";
$cert = "";
open( FD, "$fileName" ) or die "Can't access $fileName\n\n";
while( $tmp = <FD> ) {
next if ( ($cert eq "") and ($tmp !~ /BEGIN CERTIFICATE/ ));
$cert .= $tmp;
}
close( FD );

이건 아시겠죠?...

perl 기본 문법을 공부하심이 좋을것같네요..

공부하면..한결 수월해질것입니다...

익명 사용자의 이미지

거의 같은 내용의 글을 세번 올리셨군요.

이전에 올리신 글은 다 지웠습니다.

같은 글을 여러번 올리는 일은 삼가해 주시고

http//kldp.org/KoreanDoc/html/Beginner_QA-KLDP/

를 꼭 한번 읽어봐 주시기 바랍니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.