in reply to When can the character length of a Perl Scalar become an issue?

No SSCCE?

Update: example:

#!/usr/bin/perl use strict; use warnings; use Mojo::DOM; use feature 'say'; my $derp = 'x' x 30000; my $dom = Mojo::DOM->new('<?xml version="1.0"?><herp><derp>Test</derp> +</herp>'); say length ( $dom->at( 'derp' )->text ); $dom->at( 'derp' )->content( $derp ); say length ( $dom->at( 'derp' )->text ); #say $dom;
  • Comment on Re: When can the character length of a Perl Scalar become an issue?
  • Download Code

Replies are listed 'Best First'.
Re^2: When can the character length of a Perl Scalar become an issue?
by misterperl (Friar) on Sep 20, 2023 at 15:53 UTC
    I'm not sure what this tells me? It all ran fine. As I said sometimes it trucates sometimes not.
    Enter h or 'h h' for help, or 'man perldebug' for more help. main::(./y.pl:6): my $derp = 'x' x 30000; DB<1> n main::(./y.pl:7): my $dom = Mojo::DOM->new('<?xml version="1.0"? +><herp><derp>Test</derp> main::(./y.pl:8): +</herp>'); DB<1> main::(./y.pl:9): say length ( $dom->at( 'derp' )->text ); DB<1> 4 main::(./y.pl:10): $dom->at( 'derp' )->content( $derp ); DB<1> main::(./y.pl:11): say length ( $dom->at( 'derp' )->text ); DB<1> 30000 main::(./y.pl:12): say $dom; DB<1> <?xml version="1.0"?><herp><derp>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (30,000 printed total)</derp> +</herp> Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<1>

      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.

        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;