Um, if you "tried that", I assume you mean that you ran the code as I posted it. I know that what I posted compiles without errors or warnings; I don't have your data to test it on, but when I save the script as "j.pl" and run it on any file I have like this:
j.pl some.file
I consistently get a message like this printed to STDERR:
j.pl: got exactly nnn bytes from some.file
where "nnn" turns out to be the actual size of the data file provided as a command-line arg.

So what sort of message did it print to STDERR when you ran it? If the message was "got exactly nnnnn bytes from your.file", and your.file happens to have nnnnn bytes, then the read was successful, and you are simply having trouble viewing all the data -- that is, the problem is not in the perl script, but instead would be in your display tool, and in how that tool handles this data stream.

It could perhaps be something in the data file itself that is causing your display tool (terminal window? browser? something else?) to behave in some unexpected way -- e.g. some unexpected control byte is causing it to overwrite or otherwise erase/obliterate part of the data that is being given to it for display.

Consider looking for other ways to inspect the data so you can see what is going on. Redirect the perl script output to a file, edit that file with some trustworthy editor (emacs, vi, or somesuch), view it with some sort of hex-dump tool, etc.

If you ran the script as I posted it, then there should be no line breaks in the output -- just spaces. For fun, you could try changing that last line before the print statement; instead of this:

s/\s+/ /g;
do this:
s/\s+/\n/g;
to put each non-space token on a separate line. If you have something like the gnu "less" (unix "more") for paging through a long file in a terminal window, that should convince you that the perl script is not losing any of the data.

In reply to Re^3: string gets front truncated by graff
in thread string gets front truncated by hsfrey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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, details, 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, summary, 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.