Re: how to write a "od -bc" like function?
- From: Josef Moellers <josef.moellers@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 31 Aug 2007 08:56:52 +0200
jck11 wrote:
hi all
Could any one give me a direction to write a function to match the unix-like
function "od -bc" do.
Now I only get the idea of opening the file.
open(IN, "filename")or die;
my $str=<IN>;
.............
close(IN);
By the way, if the file is a exe or image type, the $str seems don't work
correctly.
Apart from the usual: three-argument "open", lexical filehandles, and explicit '<':
1. if you're dealing with binary files, you must tell perl this: "binmode IN;" after open(...), and
2. you're not reading "strings" of *characters* but "blocks" of *binary* data, so better use "read(...)".
so
perldoc -f binmode
perldoc -f read
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
.
- Follow-Ups:
- Re: how to write a "od -bc" like function?
- From: John W. Krahn
- Re: how to write a "od -bc" like function?
- References:
- how to write a "od -bc" like function?
- From: jck11
- how to write a "od -bc" like function?
- Prev by Date: Re: how to write a "od -bc" like function?
- Next by Date: FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?
- Previous by thread: Re: how to write a "od -bc" like function?
- Next by thread: Re: how to write a "od -bc" like function?
- Index(es):
Relevant Pages
|