Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Is there a length limit to a string? In a flat file?

by kiat (Vicar)
on Dec 21, 2001 at 16:56 UTC ( #133747=categorized question: print w/replies, xml ) Need Help??
Contributed by kiat on Dec 21, 2001 at 16:56 UTC
Q&A  > strings



Is there a length limit to how long a line of text can be stored in a flat file, without any line breaks? Does having longer lines make perl more error prone, ceteris paribus?


Answer: Is there a length limit to a string? In a flat file?
contributed by Biker

Juerd already answered this from a Perl point of view. I'll answer the file oriented part of the question:

A file does have no notion of 'lines'. A file is an ordered collection of bytes with specific values. It is the software that reads and/or writes the file that decides what a line is.

The convention says that in the DOS/Windows world a line is delimited by CRLF and that in the UNIX world a line is delimited by LF. But this is only a convention. (Which is clearly indicted by the fact that DOS and UNIX have different conventions. ;-)

As long as your file system can cope with it, you can make the file as big as you want. You can thereby store as long a 'line' as you want in the file.

Answer: Is there a length limit to a string? In a flat file?
contributed by Juerd

Perl has no string length limit.
You are only limited by the amount of memory that is available. Fortunately, having long strings does not make perl more error prone. Perl is famous for its great string capabilites.

Please (register and) log in if you wish to add an answer

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (3)
    As of 2021-03-01 00:43 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found