ÿþ<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" encoding='UTF-8'> <head> <meta http-equiv="Content-Type" content="text/html; charset="UTF-8" /> <title>@0:B8G5A:> ?@>3@0<8@0=5 A Perl</title> <link rel="stylesheet" href="/styles-site.css" type="text/css" /> <link rel="alternate" type="application/rss+xml" title="RSS" href="index.rdf" /> <link rel="alternate" type="application/atom+xml" title="Atom" href="atom.xml" /> <link rel="EditURI" type="application/rsd+xml" title="RSD" href="rsd.xml" /> <style type="text/css"> #AutoNumber1, #AutoNumber2, #AutoNumber3, #AutoNumber4, #AutoNumber5, #AutoNumber6, #AutoNumber7, #AutoNumber8, #AutoNumber9, #AutoNumber10, #AutoNumber11, #AutoNumber12, #AutoNumber13, #AutoNumber14, #AutoNumber15, #AutoNumber16, #AutoNumber17, #AutoNumber18, #AutoNumber19, #AutoNumber20, { text-align: left; font-family: Lucida Console, Terminal, monospace } #AutoNumber6 td { text-align: left; } p.MsoNormal {mso-style-parent:""; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman"; margin-left:0cm; margin-right:0cm; margin-top:0cm} li.MsoNormal {mso-style-parent:""; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman"; margin-left:0cm; margin-right:0cm; margin-top:0cm} .whiteColour { color: #FFFFFF } </style> <script language="javascript" type="text/javascript"> function OpenComments (c) { window.open(c, 'comments', 'width=480,height=480,scrollbars=yes,status=yes'); } function OpenTrackback (c) { window.open(c, 'trackback', 'width=480,height=480,scrollbars=yes,status=yes'); } </script> </head> <body> <div id="camelContent"> <div id="banner"> <a href="/" accesskey="1">@0:B8G5A:> ?@>3@0<8@0=5 A Perl</a><Br><span class="description"># =0?8H8 8458B5 A8 A :>4</span> </div> <div id="designedby"> dzgn&amp;concpt::jr* </div> <div id="bigmenubox"> <div id="menuxy"> <a href="/archives/cat_news.html" class="menuEntry"> =>28=8 </a><a href="/archives/cat_files.html" class="menuEntry"> <0B5@80;8 </a><a href="/archives/cat_assignments.html" class="menuEntry"> 7040G8 </a><a href="/curriculum.html" class="menuEntry"> ?@>3@0<0 </a><a href="http://perl.phreedom.org/cyberdyne/" class="menuEntry"> D>@C< </a><a href="http://perl.phreedom.org/cyberdyne/?o=testRegPage&amp;noForumsList=1" class="menuEntry"> B5AB </a> </div> <div>   </div> </div> <div id="content"> <div id="bigmenuboxfinish"> <div align="center"> <center> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="95%" id="AutoNumber2"> <tbody> <tr> <td width="100%"> <p class="MsoNormal" align="center"> <br /> <br /> <span lang="bg" style="font-size: 12pt; font-family: Century Gothic">01>@ ?@8<5@8 70 <$ <br> </span><font size="2"></span></font></span></b>&#160;&#160;</p> <div align="center" ></div> <p class="MsoNormal" align="left"><span lang="bg"><b><font face="Verdana"><br> @8<5@ 0</font></b></span></p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt" dir="ltr"> <font size="2"><span lang="bg"><span style="font-family: Verdana">5<>=AB@8@0 G5B5=5 =0 40==8 >B AB0=40@B=8O 2E>4 (STDIN) A &quot;480<0=B5=8O&quot; >?5@0B>@ (&lt;&gt;) 70 2E>4. @8 87?J;=5=85 157 ?0@0<5BJ@, 2E>40 A5 872J@H20 8;8 >B STDIN 8;8 ?>A;54>20B5;=> >B D09;>25B5, ?>4045=8 :0B> ?0@0<5B@8 A;54 8<5B> =0 ?@>3@0<0B0. @ARGV 5 <0A820, AJ4J@60I ?0@0<5B@8B5 ?>4045=8 =0 ?@>3@0<0B0. 0718@0 A5, B>9 <>65 40 1J45 ?@><5=O= >B A0<0B0 ?@>3@0<0, :0B> ?> B>78 =0G8= A5 A8<C;8@0 ?>4020=5B> =0 ?0@0<5B@8. >A;54=>B> 87?>7;20<5, 70 40 D>@A8@0<5 G5B5=5B> A &lt;&gt; 40 AB020 >B D09;>25B5 example.0.pl 8 example.1.pl. @>1209B5 40 AB0@B8@0B5 ?@8<5@0 A 8 157 ?0@0<5B@8.</span></span></font><br> &nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber11" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="389"> source code ( example.0.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="216"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="389" height="23"><p><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl</strong></font></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># '5B5=5 =0 40==8 >B STDIN 2 A:0;0@5= :>=B5:AB</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> print &quot;Enter data ('ENTER' for end):\n&quot;;<br> $a = &lt;STDIN&gt;;<br> print &quot;Inputted: $a \n&quot;;</font></strong></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># '5B5=5 =0 40==8 >B STDIN 2 A?8AJG5= :>=B5:AB</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> print &quot;Enter data ('EOF' symbol for end):\n&quot;;<br> @b = &lt;STDIN&gt;;<br> print &quot;Inputted:\n&quot;, @b;</font></strong></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># '5B5=5 =0 40==8 2 A:0;0@5= :>=B5:AB</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> $a = &lt;&gt;;<br> print &quot;Inputted: $a \n&quot;;</font></strong></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># '5B5=5 =0 40==8 2 A?8AJG5= :>=B5:AB</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> @b = &lt;&gt;;<br> print &quot;Inputted:\n&quot;, @b;</font></strong></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># 7G0:20=5 70 ENTER >B STDIN</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> &lt;STDIN&gt;;</font></strong></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># 0A82JB @ARGV AJ4J@60 ?0@0<5B@8B5 ?>4045=8 =0 2AO:0 <br> # ?@>3@0<0 8 <>65 40 1J45 ?@><5=O=</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> @ARGV = (&quot;example.0.pl&quot;,&quot;example.1.pl&quot;);<br> while (&lt;&gt;) {<br> &nbsp;&nbsp;&nbsp;&nbsp;print &quot;line: $_&quot;;<br> }</font></strong></p> </td> <td width="216" height="23"> <p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">87E>4JB 5 B2J@45 4J;J3, 0 8 7028A8 >B 2E>40 8 70 B>20 =5 5 ?C1;8:C20=</font></td> </tr> </table> </center> </div> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left"><span lang="bg"><b><font face="Verdana">@8<5@ 1</font></b></span></p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt" dir="ltr"> <font size="2"><span lang="bg"><span style="font-family: Verdana">@8<5@JB 45<>=AB@8@0 AJ:@0B5=8O 70?8A 70 G5B5=5 =0 40==8 >B AB0=40@B=8O 2E>4 8 C?>B@510B0 =0 <strong>chomp</strong> (7015;565B5 @57C;B0B0 ?@8 2B>@>B> G5B5=5 =0 40==8B5).</span></span></font><br> &nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber11" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="389"> source code ( example.1.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="216"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="389" height="23"><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl </strong></font><font face="Terminal"> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># '5B5 4> EOF</em></font><strong><font color="#FFFFFF" size="2"><br> print &quot;Enter data:\n&quot;;<br> while (defined($line = &lt;STDIN&gt;)) {<br> &nbsp;&nbsp;&nbsp;&nbsp;print $line;<br> }</font></strong></p> <p><strong><font color="#FFFFFF" size="2">print &quot;\nEnter data:\n&quot;;<br> </font></strong><font face="Terminal"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># '5B5 4> EOF, => 2 ?>-:@0BJ: 70?8A</em></font></font><strong><font color="#FFFFFF" size="2"><br> while (&lt;STDIN&gt;) {<br> &nbsp;&nbsp;&nbsp;&nbsp;chomp;<br> &nbsp;&nbsp;&nbsp;&nbsp;print;<br> }</font></strong></p> </font></td> <td width="216" height="23"> <p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">Enter data:<br> test line<br> test line<br> ^Z</font> <p><font color="#FFFFFF" size="2" face="Terminal">Enter data:<br> test line 2<br> test line 2test line 3<br> test line 3^Z</font><font color="#FFFFFF" size="2" face="Terminal"><br> </font></p> </td> </tr> </table> </center> </div> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left"><span lang="bg"><b><font face="Verdana">@8<5@ 2</font></b></span></p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt"> <font size="2"><span lang="bg"><span style="font-family: Verdana">@8<5@JB ?>:0720 C?>B@510B0 =0 >?5@0B>@8B5 70 87E>4 - <strong>print</strong>, <strong>printf</strong>, :0:B> 8 70 D>@<0B8@0=5 =0 AB@8=3 <strong>sprintf</strong>. > ?>4@0718@0=5 <strong>print</strong> 8 <strong>printf</strong> 87?>;720B STDOUT 70 87E>4.</span></span></font></p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt">&nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber19" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="389"> source code ( example.2.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="216"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="389" height="23"><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl </strong></font><font face="Terminal"> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># print 2@JI0 true, 0:> 5 8725;0 CA?5H=> AJ>1I5=85B><br> </em></font><em><font color="#FFFFFF" size="2"></font></em><font color="#FFFFFF" size="2"><strong> $a = print(&quot;hello &quot;, &quot;chixen&quot;, &quot;\n&quot;);</strong></font></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># print <>65 40 ?>;CG020 A?8AJ: >B ?0@0<5B@8, => 3@5H=> <br> # ?>AB025=8B5 A:>18 ?@><5=OB :>=B5:AB0</em></font><font color="#FFFFFF" size="2"><strong><br> print (2+3),&quot;hello\n&quot;; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><font face="Arial, Helvetica, sans-serif"><em># 3@5H=>, ?@8=B8@0 A0<> 5</em></font><strong><br> print ((2+3),&quot;hello\n&quot;);<br> print 2+3,&quot;hello&quot;,&quot;\n&quot;;</strong></font></p> <p><font face="Terminal"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># printf 8725640 D>@<0B8@0= AB@8=3 8 2@JI0 true ?@8 CA?5E</em></font></font><strong><font color="#FFFFFF" size="2"><br> printf (&quot;%.2f\n&quot;, 3.3-2);<br> </font></strong><font face="Terminal"><font face="Terminal"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># sprintf 2@JI0 D>@<0B8@=0 AB@8=3, BO =5 5 >?5@0F8O 70 <br> # 87E>4</em></font></font></font><strong><font color="#FFFFFF" size="2"><br> print sprintf (&quot;<font face="Terminal"><strong>%.2f\n&quot;, 3.3-2</strong></font>);<br> </font></strong></p> </font></td> <td width="216" height="23"> <p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">hello chixen<br> 55hello<br> 5hello<br> 1.30<br> 1.30<br> </font> </td> </tr> </table> </center> </div> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left"><span lang="bg"><b><font face="Verdana">@8<5@ 3 </font></b></span></p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt" dir="ltr"> <font size="2"><span style="font-family: Verdana" lang="bg">5<>=AB@8@0 @07;8G=8B5 @568<8, 2 :>9B> <>65 40 A5 >B2>@8 4045= D09; - 70 G5B5=5, ?8A0=5 8 4>102O=5. @8 ?>A;54=8B5 420 @568<0, 0:> D09;JB =5 AJI5AB2C20, A5 AJ74020. @>3@0<0B0 45 D0:B>, :>?8@0 example.3.pl 2 test.3.pl, A;54 :>5B> 4>102O AJ4J@60=85B> =0 ?J@28O >I5 254=J6 2 :@0O =0 test.3.pl.</span></font><br> &nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber12" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="379"> source code ( example.3.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="226"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="379" height="23"><p><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl</strong></font></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># B20@O D09; 70 G5B5=5, ?@>25@O20 70 3@5H:0</em></font><font color="#FFFFFF" size="2" face="Terminal"><strong><br> open (FILE, &quot;example.3.pl&quot;) || die &quot;Error opening file: $!&quot;;<br> </strong><font face="Arial, Helvetica, sans-serif"><em># 7G8B0 2A8G:8 @54>25 >B D09;0</em></font><strong><br> @file_lines = &lt;FILE&gt;;<br> close (FILE);</strong></font></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># B20@O D09; 70 ?8A0=5, ?@>25@O20 70 3@5H:0</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> open (FILE, &quot;&gt;test.3.pl&quot;) || die &quot;Error opening file: $!&quot;;<br> print STDOUT @file_lines;<br> </font></strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># 8H5 2J2 D09;0</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> print FILE @file_lines;<br> close (FILE);</font></strong></p> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># B20@O D09; 70 4>102O=5, ?@>25@O20 70 3@5H:0</em></font><strong><font color="#FFFFFF" size="2" face="Terminal"><br> open (FILE, &quot;&gt;&gt;test.3.pl&quot;) || die &quot;Error opening file: $!&quot;;<br> print FILE @file_lines;<br> close (FILE);</font></strong></p></td> <td width="226" height="23"><p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">87E>4JB 5 sosurce :>40 =0 example.3, :>8B> A5 28640 2 ;O2> >B B>20, :>5B> G5B5B5 2 <><5=B0 :)</font></p> </td> </tr> </table> </center> </div> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left"><span lang="bg"><b><font face="Verdana"><br> @8<5@ 4</font></b></span></p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt" dir="ltr"> <font size="2"><span lang="bg"><span style="font-family: Verdana">@>3@0<B0 G5B5 >B AB0=40@B=8O 2E>4 ?>A;54>20B5;=> 8<5=0 =0 D09;>25 8 87?>;7209:8 >?5@0B>@0 70 ?@>25@:0 AB0BCA0 =0 D09;>25 -X, 2J2 D>@<0B0 <C -e, ?@>25@O20 40;9 D09;0 AJI5AB2C20. @5:@0BO20 87?J;=5=85 ?@8 EOF. ?5@0B>@JB -X 8<0 =04 20 @07;8G=8 D>@<8, A :>9B> <>65 40 A5 ?@>25@O20B <=>65AB2> =5I0 70 D09;>25B5 (?@8<5@: -d - 70 B>20 40;8 D09;JB 5 48@5:B>@8O, -x - 40;8 5 87?J;=8<, -r - 40;8 8<0<5 ?@020 40 3> G5B5< 8 B.=.).</span></span></font><br> &nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber13" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="324"> source code ( example.4.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="281"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="324" height="23"><p dir="ltr"><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl</strong></font> <p><strong><font color="#FFFFFF" size="2" face="Terminal">print &quot;Enter filename:&quot;;<br> while ($file = &lt;STDIN&gt;) {<br> &nbsp;&nbsp; </font></strong><strong><font color="#FFFFFF" size="2" face="Terminal"> &nbsp;chomp $file;<br> &nbsp;&nbsp;&nbsp;&nbsp;if (-e $file) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;File: $file exists\n&quot;;<br> &nbsp;&nbsp;&nbsp;&nbsp;} else {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;File: $file doesn't exists\n&quot;; <br> &nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;print &quot;Enter filename:&quot;;<br> }</font></strong></p> </td> <td width="281" height="23"> <p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">Enter filename:test<br> File: test doesn't exists<br> Enter filename:example.4.pl<br> File: example.4.pl exists<br> Enter filename:^Z</font></td> </tr> </table> </center> </div> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left"><span lang="bg"><b><font face="Verdana"><br> @8<5@ 5</font></b></span></p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt"> <font size="2"><span style="font-family: Verdana" lang="bg">@8<5@JB 45<>=AB@8@0 C?>B@510B0 =0 DC=:F88B5 <strong>unlink</strong> 8 <strong>rename</strong>, AJ>B25B=> 87?>7;20=85 70 87B@820=5 8 ?@58<5=20=5 =0 D09;>25. >;720=5B> =0 <strong>unlink</strong> =04 48@5:B>@88, <>65 40 4>2545 4> ?@>1;5<8 A D09;>20B0 A8AB5<0 8 =5 5 ?@5?>@JG8B5;=>. >2545=85B> =0 <strong>rename</strong> AJI> 20@8@0 2 7028A8<>AB >B >?5@0F8>=0B0 A8AB5<0, :>OB> 87?>;720B5.</span></font><br> &nbsp;</p> <p class="MsoNormal" align="left">&nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber14" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="376"> source code ( example.5.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="229"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="376" height="23"><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl </strong></font><font face="Terminal"> <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># >:0720 AJ4J@60=85B> =0 B5:CI0B0 48@5:B>@8O, <br> # ?>A@54AB2>< :><0=40 =0 OS-0 (@01>B8 A0<> 70 OS-8, <br> # :J45B> :><0=40B0 AJI5AB2C20)</em></font><strong><font color="#FFFFFF" size="2"><br> print join ' ', `dir`;<br> <br> </font></strong><font face="Terminal"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># 7B@820 D09;0 AJ74045= 2 ?@548H=8O ?@8<5@</em></font></font><strong><font color="#FFFFFF" size="2"><br> unlink &quot;test.3.pl&quot;;<br> </font></strong><font face="Terminal"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># 7G0:20 ENTER >B STDIN</em></font></font><strong><font color="#FFFFFF" size="2"> <br> &lt;STDIN&gt;;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">print join ' ', `dir`;<br> &lt;STDIN&gt;;</font></strong></p> <p><font face="Terminal"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># !J74020 D09;</em></font></font><strong><font color="#FFFFFF" size="2"><br> open FILE, &quot;&gt;test.5.txt&quot; || die &quot;Error: $!\n&quot;;<br> print FILE &quot;test&quot;;<br> close FILE;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">print join ' ', `dir`;<br> &lt;STDIN&gt;;</font></strong></p> <p><font face="Terminal"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><em># @58<5=C20 D09;0</em></font></font><strong><font color="#FFFFFF" size="2"><br> rename &quot;test.5.txt&quot;, &quot;test.5.bak&quot;;<br> print join ' ', `dir`;</font></strong></p> </font></td> <td width="229" height="23"> <p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">@57C;B0BJB =5 5 ?C1;8:C20=, BJ9 :0B> 7028A8 >B AJ4J@60=85B> =0 48@5:B>@8OB0, 2 :>OB> 5 87?J;=5= </font></td> </tr> </table> </center> </div> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" align="left"><span lang="bg"><b><font face="Verdana"><br> @8<5@ 6</font></b></span></p> <p class="MsoNormal" align="left">&nbsp;</p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt"> <font size="2"><span lang="bg"><span style="font-family: Verdana">5<>=AB@8@0 @01>B0 A 48@5:B>@88, :0:B> 8 B>20, G5 A BOE A5 >?5@8@0 ?>4>1=> =0 D09;>25B5 - A E5=4;J@8 70 48@5:B>@88. @>3@0<0B0 459AB20 ?>4>1=> =0 ls 8;8 dir, :0B> ?>:0720 AJ4J@60=85B> =0 48@5:B>@88OB0 ?>4045=0 :0B? ?J@28 ?0@0<5BJ@.  A;CG09, G5 ;8A?20 B0:J2 8;8 B>20 5 =520;84=0 48@5:B>@8O A5 ?>0:720 B5:CI0B0.</span></span></font></p> <p class="MsoNormal" align="left">&nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber15" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="324"> source code ( example.6.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="281"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="324" height="23"><font size="2" face="Terminal"><strong><font color="#FFFFFF">#!/usr/bin/perl </font></strong></font><font face="Terminal"> <p><font color="#FFFFFF"><strong><font size="2">$dir = $ARGV[0];</font></strong></font></p> <p><font color="#FFFFFF"><font face="Terminal"><font color="#FFFFFF"><font size="2"><em><font face="Arial, Helvetica, sans-serif"># @>25@O20<5 20;84=0 ;8 5 48@5:B>@8OB0</font></em></font></font></font><strong><font size="2"><br> unless (-d $dir) {<br> &nbsp;&nbsp;&nbsp; print &quot;'$dir' is not a valid directory, using the current directory!\n&quot;;<br> &nbsp;&nbsp;&nbsp;&nbsp;$dir = '.';<br> }<br> </font></strong><font size="2"> <em><font face="Arial, Helvetica, sans-serif"># !<5=O<5 B5:CI0B0 48@5:B>@8O</font></em><strong><br> chdir $dir || die &quot;Error while chdir to $dir: $!\n&quot;;</strong></font></font></p> <p><font color="#FFFFFF"><strong><font size="2">opendir (DIR, $dir) || die (&quot;Error opening dir: $!\n&quot;);</font></strong></font></p> <p><font color="#FFFFFF"><font face="Terminal"><font color="#FFFFFF"><font size="2"><em><font face="Arial, Helvetica, sans-serif"># 78<0<5 A?8AJ: A D09;>25B5 8 3> A>@B8@0<5</font></em></font></font></font><strong><font size="2"><br> @files = sort readdir(DIR);<br> <br> print join &quot;\n&quot;, @files;</font></strong></font></p> </font> <p><font color="#FFFFFF"><strong><font size="2" face="Terminal">close (DIR);</font></strong><font size="2" face="Terminal"><font face="Terminal" size="2"><em></em></font></font></font></p> </td> <td width="281" height="23"><p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">'' is not a valid directory, using the current directory!<br> .<br> ..<br> example.0.pl<br> example.1.pl<br> example.2.pl<br> example.3.pl<br> example.4.pl<br> example.5.pl<br> example.6.pl<br> </font></td> </tr> </table> <p>&nbsp;</p> <p align="left"><span lang="bg"><b><font face="Verdana">@8<5@ 7 </font></b></span></p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt"> <font size="2"><span lang="bg"><span style="font-family: Verdana">@8<5@JB ?>:0720 C?>B@510B0 =0 DC=:F88B5 telldir, readdir, stat 8 localtime. $C=:F8OB0 stat ?@8;>65=0 =04 D09;>2 E5=4;J@ 8;8 8<5 2@JI0 <0A82 >B 45B09;8 >B=>A=> D09;0. "C: A5 ?>7;20 70 =0<8@0=5 3>;5<8=0B0 =0 D09;0 8 40B0B0, 2 :>OB> 5 18; ?@><5=O= 70 ?>A;54=>. $C=:F8OB0 localtime 2@JI0 D>@<0B8@0= AB@8=3 A 2@5<5B> =0 <0H8=0B0, 0 ?>;CG020 :0B> ?0@0<5BJ@ A5:C=48B5 87<8=0;8 >B =0G0;>B> =0 epoch (00:00:00, January 1, 1904 70 MacOS 8 00:00:00 UTC, January 1, 1970 70 ?>25G5B> 4@C38 OS).</span></span></font></p> <p class="MsoNormal" align="left">&nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber15" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="324"> source code ( example.7.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="281"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="324" height="23"><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl </strong></font><font face="Terminal"> <p><strong><font color="#FFFFFF" size="2">$dir = $ARGV[0];</font></strong></p> <p><font face="Terminal"><font color="#FFFFFF"><font face="Terminal"><font color="#FFFFFF"><font size="2"><em><font face="Arial, Helvetica, sans-serif"># @>25@O20<5 20;84=0 ;8 5 48@5:B>@8OB0</font></em></font></font></font></font></font><strong><font color="#FFFFFF" size="2"><br> unless (-d $dir) {<br> &nbsp;&nbsp;&nbsp;&nbsp;print &quot;'$dir' is not a valid directory, using the current directory!\n&quot;;<br> &nbsp;&nbsp;&nbsp;&nbsp;$dir = '.';<br> }<br> </font></strong><br> <font color="#FFFFFF"><font size="2"><em><font face="Arial, Helvetica, sans-serif"># !<5=O<5 B5:CI0B0 48@5:B>@8O</font></em><strong><br> chdir $dir || die &quot;Error while chdir to $dir: $!\n&quot;;<br> </strong></font></font><br> <strong><font color="#FFFFFF" size="2">opendir (DIR, $dir) || die (&quot;Error opening dir: $!\n&quot;);</font></strong> </p> <p><strong><font color="#FFFFFF" size="2">$dir_pos = telldir (DIR);<br> $file = readdir (DIR);<br> do {<br> &nbsp;&nbsp;&nbsp;&nbsp;print &quot;$dir_pos\t$file\t &quot; . (stat($file))[7] . &quot;\t&quot; . localtime((stat($file))[9]) . &quot;\n&quot;;<br> &nbsp;&nbsp;&nbsp;&nbsp;$dir_pos = telldir(DIR);<br> } while ($file = readdir(DIR));<br> print join &quot;\n&quot;, @files;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">close (DIR);</font></strong></p> </font></td> <td width="281" height="23"><p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">'' is not a valid directory, using the current directory!<br> 0 . 0 Thu Mar 20 17:31:44 2003<br> 2 .. 0 Thu Mar 20 17:23:54 2003<br> 5 example.0.pl 656 Thu Mar 20 12:19:04 2003<br> 18 example.1.pl 215 Thu Mar 20 12:37:06 2003<br> 31 example.2.pl 499 Thu Mar 20 15:47:39 2003<br> 44 example.3.pl 540 Thu Mar 20 15:23:23 2003<br> 57 example.4.pl 223 Thu Mar 20 15:28:27 2003<br> 70 example.5.pl 534 Thu Mar 20 15:48:44 2003<br> 83 example.6.pl 454 Thu Mar 20 17:05:05 2003<br> 96 example.7.pl 589 Thu Mar 20 17:31:30 2003</font></td> </tr> </table> <p align="left">&nbsp;</p> <p align="left"><span lang="bg"><b><font face="Verdana">@8<5@ 8</font></b></span></p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt"> <font size="2"><span lang="bg"><span style="font-family: Verdana">@8<5@JB 45<>=AB@8@0 @01>B0 A D09;>25 A ?@>872>;5= 4>ABJ?. 0:B> A5 28640, =O<0 =C640 >B ?>-@07;8G=> >B20@O=5 =0 D09;0. 7?>;720B A5 DC=:F88B5 <strong>seek</strong> 8 <strong>tell</strong> 70 CAB0=>O220=5 =0 D09;>28O C:070B5; 8 <strong>print</strong>, <strong>read</strong> 8 <strong>getc</strong> 70 2E>4/87E>4.</span></span></font></p> <p class="MsoNormal" align="left">&nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber15" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="324"> source code ( example.8.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="281"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="324" height="23"><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl </strong></font><font face="Terminal"> <p><strong><font color="#FFFFFF" size="2">open (FILE, &quot;&gt;new.file&quot;) || die (&quot;Error opening file new.file: $!\n&quot;);<br> print FILE '0123456789';<br> close (FILE);</font></strong></p> <p><strong><font color="#FFFFFF" size="2">open (FILE, &quot;+&lt;new.file&quot;) || die (&quot;Error opening file new.file: $!\n&quot;);</font></strong></p> <p><strong><font color="#FFFFFF" size="2">seek FILE, 5, 0;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">print &quot;read: &quot;. getc(FILE) . &quot;\n&quot;;<br> print &quot;pos: &quot; . tell(FILE) . &quot;\n&quot;;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">seek (FILE, -2, 1);<br> print &quot;pos: &quot; . tell(FILE) . &quot;\n&quot;;<br> read (FILE, $bla, 3);</font></strong></p> <p><strong><font color="#FFFFFF" size="2">print &quot;read: $bla\n&quot;;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">truncate (FILE, 8) || die &quot;Error truncating file: $!\n&quot;;<br> print &quot;pos: &quot; . tell(FILE) . &quot;\n&quot;;</font></strong></p> </font> <p><strong><font color="#FFFFFF" size="2" face="Terminal">print &quot;read: &quot;. getc(FILE) . &quot;\n&quot;;<br> print FILE &quot;abc&quot;;<br> close(FILE);</font></strong></p> </td> <td width="281" height="23"><p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">read: 5<br> pos: 6<br> pos: 4<br> read: 456<br> pos: 10<br> read:</font> </td> </tr> </table> <p align="left"><br> <span lang="bg"><b><font face="Verdana">@8<5@ 9 </font></b></span></p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt"> <font size="2"><span lang="bg"><span style="font-family: Verdana">@8<5@JB 45<>=AB@8@0 @01>B0 A D09;>25 A ?@>872>;5= 4>ABJ?. "C: A5 87?>7;20B DC=:F88B5 <strong>sysseek</strong>, <strong>syssread</strong>, <strong>syswrite</strong>, <strong>sysopen</strong>. <09B5 2 ?@54284, G5 B5 &quot;?@5A:0G0B&quot; io, B0:0 G5 C?>B@510B0 8< 2 :><18=0F8O A 3>@=8B5 <>65 40 4>2545 4> >1J@:20=5 8 2J>1I5 =5 A5 ?@5?>@JG20!</span></span></font></p> <p class="MsoNormal" align="left">&nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber15" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="324"> source code ( example.9.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="281"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="324" height="23"><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl </strong></font><font face="Terminal"> <p><strong><font color="#FFFFFF" size="2">open (FILE, &quot;&gt;neu.file&quot;) || die (&quot;Error opening file neu.file: $!\n&quot;);<br> print FILE '0123456789';<br> close (FILE);</font></strong></p> <p><strong><font color="#FFFFFF" size="2">sys</font><font color="#FFFFFF" size="2">open (FILE, &quot;neu.file&quot;, '&lt;') || die (&quot;Error opening file neu.file: $!\n&quot;);<br> print (($string = &quot;Read: &quot;) . &quot;\n&quot;);</font></strong></p> <p><strong><font color="#FFFFFF" size="2">sysread FILE,$string,10,6;<br> print $string;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">close(FILE);</font></strong></p> <p><strong><font color="#FFFFFF" size="2">sysopen (FILE, &quot;neu.file&quot;, '&gt;') || die (&quot;Error opening file neu.file: $!\n&quot;);</font></strong></p> <p><strong><font color="#FFFFFF" size="2">$other_scalar = '0123abcdefghij';<br> syswrite (FILE, $other_scalar, 10, 4);</font></strong></p> <p><strong><font color="#FFFFFF" size="2">close(FILE);</font></strong></p> </font></td> <td width="281" height="23"><p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">Read:<br> Read: 0123456789</font> </td> </tr> </table> <p>&nbsp;</p><p align="left"><span lang="bg"><b><font face="Verdana">@8<5@ 10 </font></b></span></p> <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 18.0pt"> <font size="2"><span lang="bg"><span style="font-family: Verdana">@8<5@JB ?>:0720 87?>720=5B> =0 DC=:F8OB0 glob, :0:B> 8 =0 AJ:@0B5=8O 8 70?8A &lt;*.c&gt;, :>8B> 2@JI0B A?8AJ: >B 8<5=0B0 =0 D09;>25B5 >B3>20@OI8 =0 D09;>20B0 <0A:0. @5?>@JG20 A5 C?>B@510B0 =0 DC=:F8OB0, >B:>;:>B> =0 AJ:@0B5=8O 70?8A, >A>15=> 0:> 8<0B5 =C640 40 8=B5@?>;8@0B5 <0A:0B0 >B =O:028 ?@><5=;828. 1J@=5B5 2=8<0=85, G5 A5 2@JI0 ?J;=8O ?JB, :0:B> 5 704045= :0B> ?0@0<5BJ@, 0 =5 A0<> 8<5=0B0 =0 D09;>25B5.</span></span></font></p> <p class="MsoNormal" align="left">&nbsp;</p> <div align="center" > <center> <table border="0" cellpadding="7" cellspacing="1" style="border-collapse: collapse" width="636" id="AutoNumber15" height="23"> <tr valign="bottom"> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="324"> source code ( example.10.pl )</td> <td style="font-size:xx-small; font-family: tahoma" valign="bottom" width="281"> output</td> </tr> <tr bgcolor="#712D2D" > <td width="324" height="23"><font color="#FFFFFF" size="2" face="Terminal"><strong>#!/usr/bin/perl </strong></font><font face="Terminal"> <p><strong><font color="#FFFFFF" size="2">print &quot;Current dir status:\n&quot;;<br> $dir = '.';</font></strong></p> <p><strong><font color="#FFFFFF" size="2">@files = glob(&quot;$dir/*&quot;);<br> print join &quot;\n&quot;, @files;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">unlink &lt;*.file&gt;;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">&lt;STDIN&gt;;</font></strong></p> <p><strong><font color="#FFFFFF" size="2">print &quot;Current dir status:\n&quot;;<br> @files = glob(&quot;$dir/*&quot;);<br> print join &quot;\n&quot;, @files;</font></strong></p> </font></td> <td width="281" height="23"><p align="left" dir="ltr"><font color="#FFFFFF" size="2" face="Terminal">Current dir status:<br> ./example.0.pl<br> ./example.1.pl<br> ./example.10.pl<br> ./example.2.pl<br> ./example.3.pl<br> ./example.4.pl<br> ./example.5.pl<br> ./example.6.pl<br> ./example.7.pl<br> ./example.8.pl<br> ./example.9.pl<br> ./neu.file<br> ./new.file<br> ./pack4.tar.gz<br> Current dir status:<br> ./example.0.pl<br> ./example.1.pl<br> ./example.10.pl<br> ./example.2.pl<br> ./example.3.pl<br> ./example.4.pl<br> ./example.5.pl<br> ./example.6.pl<br> ./example.7.pl<br> ./example.8.pl<br> ./example.9.pl<br> ./pack4.tar.gz</font></td> </tr> </table> </center> </div> <p>&nbsp;</p> </center> </div> </center> </div> </center> </div> </center> </div></td> </tr> <tr> <td>&nbsp;</td> </tr> </tbody> </table> </center> </div> </div> </div> </div> </div> <div id='camelFooter'> <MTBlogIfCCLicense> <div class="syndicate"> <br /> A8G:> B>20 3>@5 ?>?040 ?>4 C40@8B5 =0 <a href="<$MTBlogCCLicenseURL$>">Creative Commons License</a>. </div> </MTBlogIfCCLicense> <div class="powered"> 0428620=> >B <br /><a href="http://www.movabletype.org">Movable Type 2.65</a><br /> <br/> 09-4>1@5 A5 28640 A <b><a target="mozilla" href="http://www.mozilla.org/products/firefox/">Firefox</a></b> 2 <b>1024E768</b> 8;8 ?>25G5. <br/> </div> </div> </body> </html>