Others have pointed out some of your other problems.
That's not what's happening. First of all you're better of
using splice then delete for this, or using some sort of
foreach loop to not write undef items of the
to the file.
What you are doing is opening the file $ARGV for writing, clobbering the previous file,
forgetting to check the return value (open can and will
fail, be sure not to ignore it!), and then you are trying
to read from this write only filehandle, and somehow not noticing
that this is happening, probably because you don't have
warnings on to get a message like:
Filehandle TO_WRITE opened only for output....
Nevertheless, the read attempt returns undef and you
never do anything in the while loop.
You should, among other things,
get rid of the while loop and probably use splice, and use -w and strict.
update (in response to malloc's node):
Yes, you do want to clobber the file in this case.
The reason I mention that its happening is that
it (combined with how the print is never ran)
explains why the file is blank.
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>
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
Want more info? How to link or
or How to display code and escape characters
are good places to start.