Hi, I seem to be making a mess of using sysread. I haven't been using perl long so I thought I'd write a simple routine which manipulates a file. The file is tab delimited with 8 columns
field1 field2 field3 field4 field5 field6 field7 field8
field6 and field7 are dates with this format. e.g.
Aug 11 2010 1:40PM
All I want to do is to get this file into an array so I can manipulate it. I tried doing this
local *IN; open(IN, "/var/tmp/myfile.dat") or die "Can't read /var/tmp/myfile.dat +: $! \n"; binmode(IN); my $buf_e = ''; my $buf_d = ''; my $BLOCK_SIZE = 8192; my @recs; # Shove the contents of file into an array while (sysread(IN, $buf_e, $BLOCK_SIZE, length($buf_e))) { push(@recs, [ $1, $2, $3, $4, $5, $6, $7, $8 ]) while ($buf_d =~ s/^(\S+)\t+(\S+)\t+(\S+)\t+(\S+)\t+(\S+)\t+(\S+ +)\t+(\S+)\t+(\S+)\n//s); } close(IN); print @recs;
But it's not working. No output is produced and I can't figure out why. Any help would be gratefully received

In reply to sysread failure 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.