⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 internet services.mht

📁 Perl 编程技巧大全。适合初学者阅读。
💻 MHT
📖 第 1 页 / 共 4 页
字号:
color=3D#00cd00>"\n"</FONT><FONT color=3D#00ffff>;</FONT>
<FONT color=3D#ff7f50>print</FONT> <FONT color=3D#00cd00>"Its tag is =
"</FONT>, $d-&gt;tag, <FONT color=3D#00cd00>"\n"</FONT><FONT =
color=3D#00ffff>;</FONT>
<FONT color=3D#bebebe>#-----------------------------
</FONT><FONT color=3D#ff7f50>print</FONT> <FONT color=3D#00cd00>"Mail =
for "</FONT>, $d-&gt;name, <FONT color=3D#00cd00>" should be sent =
to:\n"</FONT><FONT color=3D#00ffff>;</FONT>
<FONT color=3D#ff7f50>print</FONT> <FONT color=3D#ff7f50>map</FONT> =
<FONT color=3D#00ffff>{</FONT> <FONT color=3D#00cd00>"\t$_\n"</FONT> =
<FONT color=3D#00ffff>}</FONT> $d-&gt;address<FONT =
color=3D#00ffff>;</FONT>
<FONT color=3D#ff7f50>print</FONT> <FONT color=3D#00cd00>"\t"</FONT>, =
$d-&gt;country, <FONT color=3D#00cd00>"\n"</FONT><FONT =
color=3D#00ffff>;</FONT>
<FONT color=3D#bebebe>#-----------------------------
</FONT>$contact_hash =3D $d-&gt;contacts<FONT color=3D#00ffff>;</FONT>
<FONT color=3D#ffa500>if</FONT> <FONT =
color=3D#00ffff>(</FONT>$contact_hash<FONT color=3D#00ffff>)</FONT> =
<FONT color=3D#00ffff>{</FONT>
    <FONT color=3D#ff7f50>print</FONT> <FONT =
color=3D#00cd00>"Contacts:\n"</FONT><FONT color=3D#00ffff>;</FONT>
    <FONT color=3D#ffa500>foreach</FONT> <FONT =
color=3D#9ac0cd>$type</FONT> <FONT color=3D#00ffff>(</FONT><FONT =
color=3D#ff7f50>sort</FONT> <FONT color=3D#ff7f50>keys</FONT> =
%$contact_hash<FONT color=3D#00ffff>)</FONT> <FONT =
color=3D#00ffff>{</FONT>
        <FONT color=3D#ff7f50>print</FONT> <FONT color=3D#00cd00>"  =
$type:\n"</FONT><FONT color=3D#00ffff>;</FONT>
        <FONT color=3D#ffa500>foreach</FONT> <FONT =
color=3D#9ac0cd>$line</FONT> <FONT color=3D#00ffff>(</FONT>@<FONT =
color=3D#00ffff>{</FONT>$contact_hash-&gt;<FONT =
color=3D#00ffff>{</FONT>$type<FONT color=3D#00ffff>}})</FONT> <FONT =
color=3D#00ffff>{</FONT>
            <FONT color=3D#ff7f50>print</FONT> <FONT color=3D#00cd00>"   =
 $line\n"</FONT><FONT color=3D#00ffff>;</FONT>
        <FONT color=3D#00ffff>}</FONT>
    <FONT color=3D#00ffff>}</FONT>
<FONT color=3D#00ffff>}</FONT> <FONT color=3D#ffa500>else</FONT> <FONT =
color=3D#00ffff>{</FONT>
    <FONT color=3D#ff7f50>print</FONT> <FONT color=3D#00cd00>"No contact =
information.\n"</FONT><FONT color=3D#00ffff>;</FONT>
<FONT color=3D#00ffff>}</FONT>
<FONT color=3D#bebebe>#-----------------------------
</FONT></PRE></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV class=3DSECT2>
<H2 class=3DSECT2><A name=3DAEN1002>Program: expn and vrfy</A></H2>
<TABLE width=3D"100%" bgColor=3D#2f4f4f border=3D0>
  <TBODY>
  <TR>
    <TD><PRE class=3DSCREEN><FONT color=3D#f5deb3 size=3D+1><FONT =
color=3D#bebebe>#-----------------------------
#% cat &gt; expn
#!/usr/bin/perl -w
#...
#^D
#% ln expn vrfy
#-----------------------------
#% expn gnat</FONT><FONT color=3D#cdad00>@frii</FONT><FONT =
color=3D#bebebe>.com
#Expanding gnat at frii.com (gnat</FONT><FONT =
color=3D#cdad00>@frii</FONT><FONT color=3D#bebebe>.com):
#
#calisto.frii.com Hello coprolith.frii.com [207.46.130.14],
#
#    pleased to meet you
#
#&lt;gnat</FONT><FONT color=3D#cdad00>@mail</FONT><FONT =
color=3D#bebebe>.frii.com&gt;
#-----------------------------
#% expn gnat</FONT><FONT color=3D#cdad00>@frii</FONT><FONT =
color=3D#bebebe>.com
#Expanding gnat at mail.frii.net (gnat</FONT><FONT =
color=3D#cdad00>@frii</FONT><FONT color=3D#bebebe>.com):
#
#deimos.frii.com Hello coprolith.frii.com [207.46.130.14],
#
#    pleased to meet you
#
#Nathan Torkington &lt;gnat</FONT><FONT =
color=3D#cdad00>@deimos</FONT><FONT color=3D#bebebe>.frii.com&gt;
#
#
#Expanding gnat at mx1.frii.net (gnat</FONT><FONT =
color=3D#cdad00>@frii</FONT><FONT color=3D#bebebe>.com):
#
#phobos.frii.com Hello coprolith.frii.com [207.46.130.14],
#
#    pleased to meet you
#
#&lt;gnat</FONT><FONT color=3D#cdad00>@mail</FONT><FONT =
color=3D#bebebe>.frii.com&gt;
#
#
#E
#xpanding gnat at mx2.frii.net (gnat</FONT><FONT =
color=3D#cdad00>@frii</FONT><FONT color=3D#bebebe>.com):
#
#europa.frii.com Hello coprolith.frii.com [207.46.130.14],
#
#    pleased to meet you
#
#&lt;gnat</FONT><FONT color=3D#cdad00>@mail</FONT><FONT =
color=3D#bebebe>.frii.com&gt;
#
#
#Expanding gnat at mx3.frii.net (gnat</FONT><FONT =
color=3D#cdad00>@frii</FONT><FONT color=3D#bebebe>.com):
#
#ns2.winterlan.com Hello coprolith.frii.com [207.46.130.14],
#
#    pleased to meet you
#
#550 gnat... User unknown
#-----------------------------
# <FONT size=3D-1><A =
href=3D"http://pleac.sourceforge.net/include/perl/ch18/expn">download =
the following standalone program</A></FONT>
#!/usr/bin/perl -w
# expn -- convince smtp to divulge an alias expansion
</FONT><FONT color=3D#ffa500>use</FONT> <FONT =
color=3D#b2dfee>strict</FONT><FONT color=3D#00ffff>;</FONT>
<FONT color=3D#ffa500>use</FONT> <FONT =
color=3D#b2dfee>IO::Socket</FONT><FONT color=3D#00ffff>;</FONT>
<FONT color=3D#ffa500>use</FONT> <FONT =
color=3D#b2dfee>Sys::Hostname</FONT><FONT color=3D#00ffff>;</FONT>

<FONT color=3D#ffa500>my</FONT> <FONT color=3D#9ac0cd>$fetch_mx</FONT> =
=3D <FONT color=3D#cdcd00>0</FONT><FONT color=3D#00ffff>;</FONT>
<FONT color=3D#bebebe># try loading the module, but don't blow up if =
missing
</FONT><FONT color=3D#ffa500>eval</FONT> <FONT =
color=3D#00ffff>{</FONT><FONT color=3D#43cd80>    </FONT>
    <FONT color=3D#ffa500>require</FONT> <FONT =
color=3D#b2dfee>Net::DNS</FONT><FONT color=3D#00ffff>;</FONT>
    Net::DNS-&gt;import<FONT color=3D#00ffff>(</FONT><FONT =
color=3D#00cd00>'mx'</FONT><FONT color=3D#00ffff>);</FONT>
    $fetch_mx =3D <FONT color=3D#cdcd00>1</FONT><FONT =
color=3D#00ffff>;</FONT>
<FONT color=3D#00ffff>};</FONT>

<FONT color=3D#ffa500>my</FONT> <FONT color=3D#9ac0cd>$selfname</FONT> =
=3D hostname<FONT color=3D#00ffff>();</FONT>
<FONT color=3D#ffa500>die</FONT> <FONT color=3D#00cd00>"usage: $0 =
address\</FONT><FONT color=3D#cdad00>@host</FONT><FONT color=3D#00cd00> =
...\n"</FONT> <FONT color=3D#ffa500>unless</FONT> <FONT =
color=3D#cdad00>@ARGV</FONT><FONT color=3D#00ffff>;</FONT>

<FONT color=3D#bebebe># Find out whether called as "vrfy" or "expn".
</FONT><FONT color=3D#ffa500>my</FONT> <FONT =
color=3D#9ac0cd>$VERB</FONT> =3D <FONT color=3D#00ffff>(</FONT>$<FONT =
color=3D#cdcd00>0</FONT> =3D~ /ve?ri?fy$/i<FONT color=3D#00ffff>)</FONT> =
 ? <FONT color=3D#00cd00>'VRFY'</FONT> : <FONT =
color=3D#00cd00>'EXPN'</FONT><FONT color=3D#00ffff>;</FONT>
<FONT color=3D#ffa500>my</FONT> <FONT color=3D#9ac0cd>$multi</FONT> =3D =
<FONT color=3D#cdad00>@ARGV</FONT> &gt; <FONT =
color=3D#cdcd00>1</FONT><FONT color=3D#00ffff>;</FONT>
<FONT color=3D#ffa500>my</FONT> <FONT =
color=3D#9ac0cd>$remote</FONT><FONT color=3D#00ffff>;</FONT>

<FONT color=3D#bebebe># Iterate over addresses give on command line.
</FONT><FONT color=3D#ffa500>foreach</FONT> <FONT =
color=3D#ffa500>my</FONT> $combo <FONT color=3D#00ffff>(</FONT><FONT =
color=3D#cdad00>@ARGV</FONT><FONT color=3D#00ffff>)</FONT> <FONT =
color=3D#00ffff>{</FONT>
    <FONT color=3D#ffa500>my</FONT> <FONT color=3D#00ffff>(</FONT><FONT =
color=3D#9ac0cd>$name</FONT>, <FONT color=3D#9ac0cd>$host</FONT><FONT =
color=3D#00ffff>)</FONT> =3D <FONT color=3D#ff7f50>split</FONT><FONT =
color=3D#00ffff>(</FONT>/\@/, $combo<FONT color=3D#00ffff>);</FONT>
    <FONT color=3D#ffa500>my</FONT> <FONT =
color=3D#cdad00>@hosts</FONT><FONT color=3D#00ffff>;</FONT>
    $host ||=3D <FONT color=3D#00cd00>'localhost'</FONT><FONT =
color=3D#00ffff>;</FONT>
    <FONT color=3D#cdad00>@hosts</FONT> =3D <FONT =
color=3D#ff7f50>map</FONT> <FONT color=3D#00ffff>{</FONT> =
$_-&gt;exchange <FONT color=3D#00ffff>}</FONT> mx<FONT =
color=3D#00ffff>(</FONT>$host<FONT color=3D#00ffff>)</FONT>     <FONT =
color=3D#ffa500>if</FONT> $fetch_mx<FONT color=3D#00ffff>;</FONT>
    <FONT color=3D#cdad00>@hosts</FONT> =3D <FONT =
color=3D#00ffff>(</FONT>$host<FONT color=3D#00ffff>)</FONT>   <FONT =
color=3D#ffa500>unless</FONT> <FONT color=3D#cdad00>@hosts</FONT><FONT =
color=3D#00ffff>;</FONT>

    <FONT color=3D#ffa500>foreach</FONT> <FONT color=3D#ffa500>my</FONT> =
$host <FONT color=3D#00ffff>(</FONT><FONT =
color=3D#cdad00>@hosts</FONT><FONT color=3D#00ffff>)</FONT> <FONT =
color=3D#00ffff>{</FONT><FONT color=3D#43cd80> </FONT>
        <FONT color=3D#ff7f50>print</FONT> $VERB <FONT =
color=3D#98fb98>eq</FONT> <FONT color=3D#00cd00>'VRFY'</FONT> ? <FONT =
color=3D#00cd00>"Verify"</FONT> : <FONT =
color=3D#00cd00>"Expand"</FONT>,<FONT color=3D#43cd80> </FONT>
            <FONT color=3D#00cd00>"ing $name at $host =
($combo):"</FONT><FONT color=3D#00ffff>;</FONT>

        $remote =3D IO::Socket::INET-&gt;new<FONT =
color=3D#00ffff>(</FONT>
    		       <FONT color=3D#00cd00>Proto</FONT>    =3D&gt; <FONT =
color=3D#00cd00>"tcp"</FONT>,
    		       <FONT color=3D#00cd00>PeerAddr</FONT> =3D&gt; $host,
    		       <FONT color=3D#00cd00>PeerPort</FONT> =3D&gt; <FONT =
color=3D#00cd00>"smtp(25)"</FONT>,
    		   <FONT color=3D#00ffff>);</FONT><FONT color=3D#43cd80> </FONT>

        <FONT color=3D#ffa500>unless</FONT> <FONT =
color=3D#00ffff>(</FONT>$remote<FONT color=3D#00ffff>)</FONT> <FONT =
color=3D#00ffff>{</FONT><FONT color=3D#43cd80> </FONT>
            <FONT color=3D#98fb98>warn</FONT> <FONT =
color=3D#00cd00>"cannot connect to $host\n"</FONT><FONT =
color=3D#00ffff>;</FONT>
            <FONT color=3D#ffa500>next</FONT><FONT =
color=3D#00ffff>;</FONT>
        <FONT color=3D#00ffff>}</FONT>
        <FONT color=3D#ff7f50>print</FONT> <FONT =
color=3D#00cd00>"\n"</FONT><FONT color=3D#00ffff>;</FONT>

        $remote-&gt;autoflush<FONT color=3D#00ffff>(</FONT><FONT =
color=3D#cdcd00>1</FONT><FONT color=3D#00ffff>);</FONT>

        <FONT color=3D#bebebe># use CRLF network line terminators
</FONT>        <FONT color=3D#ff7f50>print</FONT> $remote <FONT =
color=3D#00cd00>"HELO $selfname\015\012"</FONT><FONT =
color=3D#00ffff>;</FONT>
        <FONT color=3D#ff7f50>print</FONT> $remote <FONT =
color=3D#00cd00>"$VERB $name\015\012"</FONT><FONT =
color=3D#00ffff>;</FONT>
        <FONT color=3D#ff7f50>print</FONT> $remote <FONT =
color=3D#00cd00>"quit\015\012"</FONT><FONT color=3D#00ffff>;</FONT>
        <FONT color=3D#ffa500>while</FONT> <FONT =
color=3D#00ffff>(</FONT>&lt;$remote&gt;<FONT color=3D#00ffff>)</FONT> =
<FONT color=3D#00ffff>{</FONT>
    	        /^<FONT color=3D#cdcd00>220</FONT>\b/ &amp;&amp; <FONT =
color=3D#ffa500>next</FONT><FONT color=3D#00ffff>;</FONT>
    	        /^<FONT color=3D#cdcd00>221</FONT>\b/ &amp;&amp; <FONT =
color=3D#ffa500>last</FONT><FONT color=3D#00ffff>;</FONT>
    	        <FONT color=3D#ff7f50>s</FONT>/<FONT =
color=3D#cdcd00>250</FONT>\b<FONT color=3D#00ffff>[</FONT>\-\s<FONT =
color=3D#00ffff>]</FONT>+//<FONT color=3D#00ffff>;</FONT>
    	        <FONT color=3D#ff7f50>print</FONT><FONT =
color=3D#00ffff>;</FONT>
        <FONT color=3D#00ffff>}</FONT><FONT color=3D#43cd80> </FONT>
        <FONT color=3D#98fb98>close</FONT><FONT =
color=3D#00ffff>(</FONT>$remote<FONT color=3D#00ffff>)</FONT>			<FONT =
color=3D#98fb98>or</FONT> <FONT color=3D#ffa500>die</FONT> <FONT =
color=3D#00cd00>"can't close socket: $!"</FONT><FONT =
color=3D#00ffff>;</FONT>
        <FONT color=3D#ff7f50>print</FONT> <FONT =
color=3D#00cd00>"\n"</FONT><FONT color=3D#00ffff>;</FONT> <FONT =
color=3D#bebebe>#  if </FONT><FONT color=3D#cdad00>@ARGV</FONT><FONT =
color=3D#bebebe>;
</FONT>    <FONT color=3D#00ffff>}</FONT>
<FONT color=3D#00ffff>}</FONT><FONT color=3D#43cd80> </FONT>

<FONT color=3D#bebebe>#-----------------------------
</FONT></PRE></FONT></TD></TR></TBODY></TABLE></DIV></DIV>
<DIV class=3DNAVFOOTER>
<HR align=3Dleft width=3D"100%">

<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"100%"=20
summary=3D"Footer navigation table" border=3D0>
  <TBODY>
  <TR>
    <TD vAlign=3Dtop align=3Dleft width=3D"33%"><A accessKey=3DP=20
      =
href=3D"http://pleac.sourceforge.net/pleac_perl/sockets.html">Prev</A></T=
D>
    <TD vAlign=3Dtop align=3Dmiddle width=3D"34%"><A accessKey=3DH=20
      =
href=3D"http://pleac.sourceforge.net/pleac_perl/index.html">Home</A></TD>=

    <TD vAlign=3Dtop align=3Dright width=3D"33%"><A accessKey=3DN=20
      =
href=3D"http://pleac.sourceforge.net/pleac_perl/cgiprogramming.html">Next=
</A></TD></TR>
  <TR>
    <TD vAlign=3Dtop align=3Dleft width=3D"33%">Sockets</TD>
    <TD vAlign=3Dtop align=3Dmiddle width=3D"34%">&nbsp;</TD>
    <TD vAlign=3Dtop align=3Dright width=3D"33%">CGI=20
Programming</TD></TR></TBODY></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -