Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

You made a significant start toward finding your problem when you discovered what you say in your comment "not appending." That kind of output error -- after some data acquisition you say is working -- is a pretty broad hint that you should look to your filehandling.

So, for starters, you might have consulted the documentation (perldoc -f open) to check the syntax of open-append:

open (writefile, ">>,$target_full_path") { # quoting changed!

I'd also suggest you change writefile to upper case (or to FH which is one conventional form) to avoid a possible clash with a future reserved word. (use warnings;</c> would have told you this. Well, it would have warned about the possible issue.)

Have you predeclared $rowcount (as a global?). ...$sth4?

Have you considered the benefits of using strict and warnings to help solve questions like this? I'm not clear what kind prior version that would have morphed to this with "slight modifications" COULD have been working.

And, FWIW, a simplified version that does work (with your comments preserved):

use strict; use warnings; my $rowcount = 0; open (FH, ">> 667868.txt") || die "Can't open 667868.txt $!"; while(<DATA>) { print $_; # it is working print FH $_; # not appending $rowcount++; # here it is counting } close FH; print $rowcount; __DATA__ now is the time for all good men to come to the aid of their country, while the quick red fox jumps over the lazy brown dog's back.

And, finally, please use <c>...<</c> tags around code. See Writeup Formatting Tips.

UpdateTwo days later: comment re quoting added with thanks to graff for pointing out that OP quoting was OK.


In reply to Re: appending data to a file by ww
in thread appending data to a file by sudeep

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2020-10-24 17:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My favourite web site is:












      Results (246 votes). Check out past polls.

      Notices?