in reply to Re^3: 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?

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;

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

Replies are listed 'Best First'.
Re^5: When can the character length of a Perl Scalar become an issue?
by marto (Cardinal) on Sep 21, 2023 at 08:42 UTC

    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.

Re^5: When can the character length of a Perl Scalar become an issue?
by NERDVANA (Priest) on Sep 22, 2023 at 03:12 UTC
    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?
Re^5: When can the character length of a Perl Scalar become an issue?
by Anonymous Monk on Sep 21, 2023 at 06:10 UTC
    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