sherab has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks, A co-worker has an issue regarding variable size and I'm stumped also. He's reading in a var that's about 200K characters and what's happening is that upon trying to print said variable, it cuts off and doesn't print the whole thing. If someone knows off the top of their head, is there a limit on how big a variable can be before perl truncates it? If it's any indication, when trying to vi the file containing the data, vi says "Line too long". Many thanks! sherab

Replies are listed 'Best First'.
Re: Limit on var sizes?
by almut (Canon) on Nov 04, 2009 at 16:28 UTC

    Perl doesn't truncate variables. Your problem must lie elsewhere.

    Could you post some (self-contained) code that demonstrates the problem?

Re: Limit on var sizes?
by ikegami (Patriarch) on Nov 04, 2009 at 16:36 UTC

    Perl can handle strings billions of characters long.

    Does the string contains any characters the terminal would interpret, such as "\r"?

    >perl -le"print qq{aaaaaaaa\rbbbbb}" bbbbbaaa
Re: Limit on var sizes?
by Capablanca (Novice) on Nov 04, 2009 at 16:53 UTC
    Perl should not truncate the variables.
    Maybe in the variable there are some special characters?
    Could You post the code?
Re: Limit on var sizes?
by MidLifeXis (Monsignor) on Nov 04, 2009 at 17:12 UTC
Re: Limit on var sizes?
by Anonymous Monk on Nov 04, 2009 at 17:06 UTC
    hexdump, and od
    $ perl -le"print qq!asd\rfrog!" frog $ perl -le"print qq!asd\rfrog!" |hexdump 00000000: 61 73 64 0D 66 72 6F 67 - 0D 0A |asd frog + | 0000000a; $ perl -le"print qq!asd\rfrog!" |od -tacx1 0000000 a s d cr f r o g cr nl a s d \r f r o g \r \n 61 73 64 0d 66 72 6f 67 0d 0a 0000012 $