in reply to Re^2: When can the character length of a Perl Scalar become an issue?
in thread When can the character length of a Perl Scalar become an issue?

Purely an SSCCE to illustrate adding 30K characters to an XML node. You're likely doing something in the code you're not showing us that causes the problem.

  • Comment on Re^3: When can the character length of a Perl Scalar become an issue?

Replies are listed 'Best First'.
Re^4: When can the character length of a Perl Scalar become an issue?
by misterperl (Friar) on Sep 20, 2023 at 16:27 UTC

    OK so first I build the scalar- the code just appends values to a long string. It can reach 40,000 or more characters, saved in scalar $E. $E has NO EOL characters. The $E gen code is hard to sanitize. Then $E is appended to a very short file:

    open A, ">>$a"; print A "$E\n"; close A;

      It's better to mark a post as updated. Again without seeing a repeatable example (see previous links) that demonstrates the problem it's difficult to help.

      #!/usr/bin/perl use strict; use warnings; my $derp = 'X' x 40000; open (my $fh, '>', 'derp.txt') or die "can't open derp.txt: $!"; print $fh $derp; close($fh);
      ls -al derp.txt -rw------- 1 marto marto 40000 Sep 21 09:37 derp.txt

      See also open, three arg open, migrating to modern perl.

      Since files are involved, and *appending* to files, is there a chance that more than one copy of your script runs at the same time, appending to the same file?
      Tough to tell without seeing the gen code...

      Best guess is some sort of ctrl char (or seq of chars that get resolved to one). If you make it gen the same line twice, does it break in the same place ?

      Cheers
      Chris