📄 521-522.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Perl</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=28//-->
<!--PAGES=521-522//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="519-521.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch29/523-526.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading22"></A><FONT COLOR="#000077">Converting Programs to Perl</FONT></H3>
<P>The Perl language is similar to other programming languages that come with Linux in the kinds of things it can do. The most significant of these languages are <TT>gawk</TT> and <TT>sed</TT>. The Perl distribution comes with two utility programs that allow you to convert <TT>sed</TT> and <TT>gawk</TT> programs into Perl programs. Because Perl is a superset of both these languages, any programs that can be written in <TT>gawk</TT> or <TT>sed</TT> can also be written in Perl. The two programs that perform these conversions are called <TT>a2p</TT> for converting <TT>gawk</TT> programs to Perl and <TT>s2p</TT> for converting <TT>sed</TT> programs to Perl.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>Note: </B><BR>The reason that the <TT>gawk</TT> to Perl conversion utility is called <TT>a2p</TT> instead of <TT>g2p</TT> is that <TT>gawk</TT> is the GNU version of another program called <TT>awk</TT>.<HR></FONT>
</BLOCKQUOTE>
<P>To run the <TT>a2p</TT> program, simply enter the following command:</P>
<!-- CODE SNIP //-->
<PRE>
a2p gawk_program >perl_program
</PRE>
<!-- END CODE SNIP //-->
<P><TT>gawk_program</TT> is the <TT>gawk</TT> program you want to convert to Perl, and <TT>perl_program</TT> is the name you want to give to your new Perl program.</P>
<P>To run the <TT>s2p</TT> program, enter the following command:</P>
<!-- CODE SNIP //-->
<PRE>
s2p sed_program >perl_program
</PRE>
<!-- END CODE SNIP //-->
<P><TT>sed_program</TT> is the name of the <TT>sed</TT> program you want to convert to Perl, and <TT>perl_program</TT> is the name you want to give to your new Perl program.</P>
<H3><A NAME="Heading23"></A><FONT COLOR="#000077">Summary</FONT></H3>
<P>This chapter introduces what is arguably the most powerful language available on Linux. Perl is a vast language. It contains operators that provide you with almost any function you could want to perform in the Linux environment. The size of the language makes becoming an expert Perl programmer difficult, but at the same time it isn’t that hard to learn to use Perl for simpler tasks.
</P>
<P>Although this chapter presents a fairly complete overview of the Perl language, it barely scratches the surface of the features that are available in Perl. If you want to learn more about Perl, refer to the Perl manual pages. You can also read more about other programming languages that are useful with Perl or find associated material in other chapters.</P>
<DL>
<DD><TT>awk</TT>, a powerful pattern-action language that complements Perl, is discussed in Chapter 25, “<TT>gawk</TT>.”
<DD>Tcl and Tk, both handy scripting utilities, are discussed in Chapter 29, “Introduction to Tcl and Tk.”
<DD>CGI programming, which Perl is particularly well-suited for, is discussed in Chapter 52, “CGI Scripts.”
</DL>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="519-521.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch29/523-526.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -