Newbie: String concatenation limited to 256 characters?

Discussion in 'Perl Misc' started by Piet, Sep 29, 2004.

  1. Piet

    Piet Guest

    Hello,
    I have written a small script that parses an (ugly) HTML file line by
    line and converts the relevant information to CSV. During parsing, I
    heavily use string concatenation to glue together parts of text that
    belong together (but might be separated in the original file by tags
    or newlines). In the code, the expression
    $oldstring = $oldstring.$newstring
    occurs very often.
    Frequently, the strings get longer than 256 characters. At this point,
    the string concatenation refuses to add anything to $oldstring. How is
    it possible to avoid that?
    Thanks in advance for answers on a (maybe very newbish) question
    Piet
    Piet, Sep 29, 2004
    #1
    1. Advertising

  2. (Piet) wrote in news:39cbe663.0409290925.2e735196
    @posting.google.com:

    > Hello,
    > I have written a small script that parses an (ugly) HTML file line by
    > line and converts the relevant information to CSV. During parsing, I
    > heavily use string concatenation to glue together parts of text that
    > belong together (but might be separated in the original file by tags
    > or newlines). In the code, the expression
    > $oldstring = $oldstring.$newstring
    > occurs very often.
    > Frequently, the strings get longer than 256 characters. At this point,
    > the string concatenation refuses to add anything to $oldstring. How is
    > it possible to avoid that?
    > Thanks in advance for answers on a (maybe very newbish) question
    > Piet


    Your post appeared twice. Please don't post multiple copies of the same
    question.

    You'll need to provide a short self-contained script that still exhibits
    the problem to support such an outrageous claim.

    #! perl

    use strict;
    use warnings;


    my $str = 'a';

    $str .= 'a' for (1 .. 999_999);

    print length($str), "\n";

    __END__



    --
    A. Sinan Unur
    d
    (remove '.invalid' and reverse each component for email address)
    A. Sinan Unur, Sep 29, 2004
    #2
    1. Advertising

  3. Piet

    Paul Lalli Guest

    "Piet" <> wrote in message
    news:...
    > Hello,
    > I have written a small script that parses an (ugly) HTML file line by
    > line and converts the relevant information to CSV. During parsing, I
    > heavily use string concatenation to glue together parts of text that
    > belong together (but might be separated in the original file by tags
    > or newlines). In the code, the expression
    > $oldstring = $oldstring.$newstring
    > occurs very often.
    > Frequently, the strings get longer than 256 characters. At this point,
    > the string concatenation refuses to add anything to $oldstring. How is
    > it possible to avoid that?
    > Thanks in advance for answers on a (maybe very newbish) question
    > Piet


    You've misdiagnosed your problem. Perl is very capable of dealing with
    arbitrarily long strings. Therefore, the strings are being cut off by
    something else. My guess would be a fixed length database field that
    you might be storing them in. Since you didn't provide any code, we
    have no way of pointing to you to what your actual problem is.

    Paul Lalli
    Paul Lalli, Sep 29, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    4,796
    walala
    Sep 18, 2003
  2. M-One
    Replies:
    43
    Views:
    1,466
    Mark McIntyre
    Jul 16, 2003
  3. Phil C.
    Replies:
    3
    Views:
    234
    Joe Kaplan \(MVP - ADSI\)
    Feb 25, 2005
  4. JV
    Replies:
    0
    Views:
    233
  5. Piet
    Replies:
    2
    Views:
    111
Loading...

Share This Page