Reading from the Perl Blackbook it says you can read a certain amount of data from a file. For some reason, it reads and prints the entire thing even though I only tell it to print 1 byte! The test file is about 2 pages long, definitely larger than a byte but everything is printing.
open(TEST, "test.txt") or die "oops: $!"; my $text = ""; while(read (TEST, $stuff, 1)) { $text .= $stuff; } print $text;
Then, I tried adding an offset of 5 thinking it will skip the first portion of it, right? Instead of printing the text, it jumped it all up
H T M L f o r m + a t ( . h t m o r . h + t m l ) t e x t / h t m + l A d o b e P o + r t a b l e D o c u m e n + t ( p d f ) a p p l i c a t i + o n / p d f M i c r o s o f + t W o r d ( . d o c ) a p p l i c a t i + o n / m s w o r d M i c r o s o f + t E x c e l ( . x l s ) a p p l i c a t i + o n / m s e x c e l M i c r o s o f + t P o w e r p o i n t ( + . p p t ) a p p l i c a t i + o n / m s - p o w e r p o i + n t R e a l a u d i + o ( . r m , . r a m ) a u d i o / x - + p n - r e a l a u d i o T e x t f o r + m a t ( . t x t ) t e x t / t x t Z i p p e d f i l e + s ( . z i p ) a p p l i c a t i o + n / z i p . a v i v i d + e o / a v i . b m p i m a + g e / b m p . g i f i m a + g e / g i f . g z i p a p p l i + c a t i o n / x - g z i p . j p g i m + a g e / j p e g . j s a p p + l i c a t i o n / x - j a v + a s c r i p t . m i d i a + p p l i c a t i o n / x - m + i d i . m p 3 a u + d i o / m p e g 3 . m p e g v i + d e o / m p e g . p n g i m a + g e / p n g . p p t a p p + l i c a t i o n / m s p o w + e r p o i n t . p s d a p p + l i c a t i o n / o c t e t + - s t r e a m . z i p a p p l i c + a t i o n / z i p . d o c a p p + l i c a t i o n / m s w o r + d = = = = = = = = = = = + = = = = = = = = = = = = = = + = = = = = = = = = = = = = + = = = = A D D L e a f 4 2 : b + i n L e a f 4 2 : c + u e L e a f 4 2 : r + a r L e a f 4 2 : w + m v L e a f 4 2 : m + d b
What in the world am I doing wrong?

In reply to Reading input byte by byte by Anonymous Monk

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.