perl.beginners
[Top] [All Lists]

Re: reading a few bytes into a file

Subject: Re: reading a few bytes into a file
From: Jenda@xxxxxxxxxxx (Jenda Krynicky)
Date: Wed, 30 Jul 2008 11:12:35 +0200
Newsgroups: perl.beginners

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


<Prev in Thread] Current Thread [Next in Thread>