First, check that you're using strict and -w. I think you're getting errors that you can't see. In that case, check your log file.

Second, the way this operates depends a lot on how you're calling it. If you're opening a pipe, it could break, and then things could fall apart.

I have a sneaking suspicion, though, that you're doing something like this:
my $file = "foo.txt"; my $data; read($file, $data, 1024);
Note that read operates on a file-handle, not a file name. These need to be opened:
my $file = "foo.txt"; open ($fh, $file) || die "Could not open file $file\n"; my $data; read($fh, $data, 1024);
If you're feeling more progressive, you might try and use IO::Handle instead of the read anachronism.

In reply to Re: read(x,y,z) by tadman
in thread read(x,y,z) by ZenOfCoding

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.