| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> |
|---|
| 3 | <head profile="http://purl.org/net/ns/metaprof"> |
|---|
| 4 | <!-- Document Metadata --> |
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 6 | <meta http-equiv="Content-Language" content="ja" /> |
|---|
| 7 | <meta http-equiv="Content-Style-Type" content="text/css" /> |
|---|
| 8 | <meta http-equiv="Content-Script-Type" content="text/javascript" /> |
|---|
| 9 | <meta http-equiv="imagetoolbar" content="no" /> |
|---|
| 10 | |
|---|
| 11 | <!-- Atom news feed --> |
|---|
| 12 | |
|---|
| 13 | <link rel="alternate" type="application/rss+xml" title="RSS feed" href="http://coderepos.org/share/log/websites/perl-users.jp?limit=100&mode=stop_on_copy&format=rss" /> |
|---|
| 14 | <link rel="stylesheet" type="text/css" href="/css/perl-users.jp.css" /> |
|---|
| 15 | <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon" /> |
|---|
| 16 | <link rel="icon" href="/favicon.ico" type="image/vnd.microsoft.icon" /> |
|---|
| 17 | |
|---|
| 18 | <title>パスワード設定をコードに書かない(Config::Pit) - モダンなPerl入門 - モダンなPerl入門</title> |
|---|
| 19 | |
|---|
| 20 | <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> |
|---|
| 21 | <script type="text/javascript"> |
|---|
| 22 | _uacct = "UA-4463402-1"; |
|---|
| 23 | urchinTracker(); |
|---|
| 24 | </script> |
|---|
| 25 | <!-- script src="/js/codepress/codepress.js" type="text/javascript"></script --> |
|---|
| 26 | </head> |
|---|
| 27 | <body> |
|---|
| 28 | <div id="head-navigation"><a href="/">Perl-users.jp</a></div> |
|---|
| 29 | <!-- content start --> |
|---|
| 30 | <h1>パスワード設定をコードに書かない(Config::Pit)</h1> |
|---|
| 31 | |
|---|
| 32 | <p>パスワード設定をコードに書かないようにするには Config::Pit をつかいます。</p> |
|---|
| 33 | |
|---|
| 34 | <h3>つかいかた</h3> |
|---|
| 35 | |
|---|
| 36 | <pre><code>use strict; |
|---|
| 37 | use warnings; |
|---|
| 38 | use Config::Pit; |
|---|
| 39 | |
|---|
| 40 | # 設定 |
|---|
| 41 | Config::Pit::set("example.com", data => { |
|---|
| 42 | username => "foobar", |
|---|
| 43 | password => "barbaz", |
|---|
| 44 | });</code></pre> |
|---|
| 45 | |
|---|
| 46 | <pre><code>use strict; |
|---|
| 47 | use warnings; |
|---|
| 48 | use Config::Pit; |
|---|
| 49 | |
|---|
| 50 | # 読み出し |
|---|
| 51 | my $config = pit_get("example.com"); |
|---|
| 52 | my $username = $config->{username}; |
|---|
| 53 | my $password = $config->{password}; |
|---|
| 54 | print "username: $username, password: $password\n";</code></pre> |
|---|
| 55 | |
|---|
| 56 | <p>Config::Pit::setで格納、pit_getで読み出します。</p> |
|---|
| 57 | |
|---|
| 58 | <h3>使用例</h3> |
|---|
| 59 | |
|---|
| 60 | <ul> |
|---|
| 61 | <li> |
|---|
| 62 | <a href="http://perl-users.jp/articles/advent-calendar/2008/21.html"> |
|---|
| 63 | Config::PitとWeb::ScraperとPlaggerで24時間365日のゲーム監視体制</a |
|---|
| 64 | > |
|---|
| 65 | </li> |
|---|
| 66 | </ul> |
|---|
| 67 | <!-- content end --> |
|---|
| 68 | <hr /> |
|---|
| 69 | <p><a href="/modern_introduction_perl/">目次へ</a></p> |
|---|
| 70 | <p>Last modified: $Date: 2009-04-08T22:19:00+09:00 $</p> |
|---|
| 71 | </body> |
|---|
| 72 | </html> |
|---|
| 73 | |
|---|