<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://halfgeek.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Inline_Perl</id>
	<title>Inline Perl - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://halfgeek.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Inline_Perl"/>
	<link rel="alternate" type="text/html" href="https://halfgeek.org/wiki/index.php?title=Inline_Perl&amp;action=history"/>
	<updated>2026-05-28T12:22:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>https://halfgeek.org/wiki/index.php?title=Inline_Perl&amp;diff=159&amp;oldid=prev</id>
		<title>161.253.9.181 at 15:04, 12 May 2005</title>
		<link rel="alternate" type="text/html" href="https://halfgeek.org/wiki/index.php?title=Inline_Perl&amp;diff=159&amp;oldid=prev"/>
		<updated>2005-05-12T15:04:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Batch processing using Perl=&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;-n&amp;lt;/code&amp;gt; switch in Perl forces the entire program to be interpreted as if in a &amp;lt;code&amp;gt;while(&amp;lt;STDIN&amp;gt;) {}&amp;lt;/code&amp;gt; loop.  More or less, this means the program is run once for each line of input, and the current line is in &amp;lt;code&amp;gt;$_&amp;lt;/code&amp;gt;.  Use &amp;lt;code&amp;gt;chomp&amp;lt;/code&amp;gt; or a regexp to get rid of the trailing newline.&lt;br /&gt;
&lt;br /&gt;
Here is how one might write &amp;lt;code&amp;gt;ls *.js&amp;lt;/code&amp;gt; using Perl as the filter:&lt;br /&gt;
&lt;br /&gt;
 ls | perl -n -e &amp;#039;/^((.*)\.js)$/ or next; print &amp;quot;$1\n&amp;quot;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
To run &amp;lt;code&amp;gt;pod2html&amp;lt;/code&amp;gt; on all .js files in a directory, writing the output for XXX.js to XXX.html, displaying each command used in the process, one could use a command like this:&lt;br /&gt;
&lt;br /&gt;
 ls | perl -n -e &amp;#039;/^((.*)\.js)$/ or next; $c=&amp;quot;pod2html $1 &amp;gt;&amp;gt; $2&amp;quot;; print &amp;quot;\n$c\n&amp;quot;; print `$c`&amp;#039;&lt;/div&gt;</summary>
		<author><name>161.253.9.181</name></author>
		
	</entry>
</feed>