Use the perl documentation installed on your machine with the binary.<br>
<br>
     perldoc perlrun<br>
<br>
describes all the command line options, including -p, -n, -i. You&#39;ll
see the file is processed line by line. Of course the system buffers
are the controlling factor for memory usager, if your lines are an
ordinary length of 80 or so characters, since the buffers are a few KB
in size<br>
<br>
<br><br><div class="gmail_quote">On Thu, Oct 1, 2009 at 9:53 PM, Viktor Pavlenko <span dir="ltr">&lt;<a href="mailto:vvp@cogeco.ca">vvp@cogeco.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">&gt;&gt;&gt;&gt;&gt; &quot;MK&quot; == Madison Kelly &lt;<a href="mailto:linux@alteeve.com">linux@alteeve.com</a>&gt; writes:<br>
<br>
    &gt;&gt; perl -i -ne &#39;print if $. &gt; 20&#39; file<br>
<br>
</div>    MK&gt; Where &#39;if&#39; is the input file handle? I&#39;ve not played with<br>
    MK&gt; &#39;$.&#39;...<br>
<br>
$. is the line number, starting from 1. `if&#39; is just an `if&#39;, you can<br>
write it traditional way: if ($. &gt; 20) { print }. It says to print $_<br>
(omitted) if the line number is greater than 20. It&#39;s a perl<br>
one-liner, it allows you to read one line at a time and put it in $_,<br>
-n means don&#39;t print it, and -i tells perl to edit the file in place<br>
(all tmp file business is taken care of). What follows -e is the<br>
script to execute.<br>
<br>
    MK&gt; &#39;If this works it&#39;d be the pure-perl way I was hoping<br>
    MK&gt; for. Do you know if this still reads the whole file into<br>
    MK&gt; memory at once? My biggest concern, even more than speed, is<br>
    MK&gt; that this may need to be done on files larger than available<br>
    MK&gt; RAM.<br>
<br>
I&#39;m sure it reads a line at a time and then throws it away, so no<br>
worries about memory. Your point about inefficiency of reading &amp;<br>
copying remains valid.<br>
<br>
HTH<br>
<br>
--<br>
<font color="#888888">Viktor<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br>
</div></div></blockquote></div><br>