Well, what most people ranting about magic open say is that files ending in '|' get created either by accident, or they are there to try to exploit something. In such cases, I would like to see the files removed; I rather have my filter stop and complain in stead of silently processing the file and leaving the potential exploit there.
Now, if you actually want to have files that start with '<', '>', '|' or whitespace, or end with '|' or whitespace, then you are in for a lot of suffering - not just from Perl, but from the shell as well. But still, Perl has a documented solution (see for instance, 'perlopentut'):
BEGIN {s!^(\s)!./$1!,s/^/</,s/$/\0/ for @ARGV}
Yes, and that works with -i as well.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|