note
osfameron
Moving from typing
<cite><code>perl foo.pl</code></cite>
to
<cite><code>foo</code></cite>
using the above method will work for standalone programs
but <i>not</i> for more complicated Command Lines, e.g.
<cite><code>foo > foo_results.txt</code></cite>
Similarly, if foo.pl is a filter (like a pager program, or
a program that makes substitutions to its input), then
<cite><code>mycommand | foo</code></cite>
also won't work.
<p>
This is due to a bug, apparently in Win32. (Though as batch
files and executables can quite happily redirect
input/output, I don't understand why it can't be
circumvented??).
<p>
A workaround is to turn any perl scripts that need to
redirect IO into a batch file, which doesn't have the same
bug... Luckily the handy
<code>pl2bat</code> program that comes standard with Win32
distributions of Perl does this, basically by putting a
batch wrapper script around your Perl code.
<blockquote><pre><code>
pl2bat foo.pl
foo.bat | more
foo | more
foo > results.txt
dir | foo
</code></pre>
</blockquote>
Note: This doesn't contradict the effectiveness of the original technique above for simple scripts though!
<p>Cheerio!<BR>
Osfameron<br>
<a href="http://osfameron.perlmonk.org/chickenman">
http://osfameron.perlmonk.org/chickenman
</a>
147234
147234