bh_perl has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Could somebody guide me how to read each 232 bytes of the input data ?
  • Comment on How to read each 232 bytes of input data ?

Replies are listed 'Best First'.
Re: How to read each 232 bytes of input data ?
by jettero (Monsignor) on Apr 06, 2007 at 07:23 UTC
    read $inputhandle, $buf, 232

    -Paul

Re: How to read each 232 bytes of input data ?
by Corion (Patriarch) on Apr 06, 2007 at 07:45 UTC

    If you want to read all your input in chunks of 232 bytes of data, you could set the magic variable $/ instead of using jettero's approach so Perl reads in records of 232 bytes length:

    $/ = \232; while (<$input>) { ... }
      Just don't forget (even better, make it 'fingertip memory') to localize $/:
      local $/ = \232; ...

      Update And as Roboticus knowingly pinpointed, I should mention here for completeness that the localization should be kept 'as local as possible', so maybe the code should look like
      { local $/ = \232; while (<$input>) { ... } }
Re: How to read each 232 bytes of input data ?
by sgt (Deacon) on Apr 06, 2007 at 11:31 UTC

    and if you want to avoid buffering you can use sysread which uses the same syntax as read (see jettero's post). 'perldoc -f read' o 'perldoc -f sysread' will tell you more

    hth --stephan