Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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 array to the file.

What you are doing is opening the file $ARGV[0] 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.


In reply to Re: writing blank array to file? by wog
in thread writing blank array to file? by dusk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found