Re: reading a few bytes into a file



From: Scott Haneda <talklists@xxxxxxxxxx>
Hello, I have this small C app that someone wrote for me ages ago, and
am tired of it breaking every time I move it around to various
systems, I will include it below.

I am hoping I can do this in perl, as a one liner, were it will read a
the first 4 bytes of a file, grab 4 bytes out of the file, which is a
big endian value, and return that as an int to me.

perldoc -f read
perldoc -f unpack
perldoc -f pack

And to simplify the code (so that you do not need to explicitely open
the file), look also into
perldoc perlvar
at the ARGV filehandle.

HTH, Jenda
===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

.



Relevant Pages

  • Re: "$| = 1" ???
    ... perldoc perlvar. ... but pointing someone to the docs is helping more than directly ... Curiously the most helpful people on this list seem to think the perldoc ... I am not saying the Perl documentation is perfect (I wouldn't be ...
    (perl.beginners)
  • Re: The $a have any special meanning ?
    ... perldoc -f sort ... I found examples in perldoc -f sort but these are examples. ... In perlvar are mentioned variables where second character is not alphabetic, for example $`, ...
    (comp.lang.perl.misc)
  • Re: "$| = 1" ???
    ... perldoc perlvar. ... but pointing someone to the docs is helping more than directly ... Curiously the most helpful people on this list seem to think the perldoc ... Everybody gets pointed back to the perldoc system, ...
    (perl.beginners)
  • Re: odd chars in perldoc prior to 5.10.0 (was: Re: How to print question)
    ... I threw this into my linux console (where perldoc ... I noticed the grep didn't return any output. ... You can eliminate term/font issues by using plain text: ...
    (comp.lang.perl.misc)
  • Re: "$| = 1" ???
    ... perldoc perlvar. ... ES> This isn't really helping, ... Curiously the most helpful people on this list seem to think the perldoc ... Everybody gets pointed back to the perldoc system, ...
    (perl.beginners)