Re: how to write a "od -bc" like function?



Josef Moellers wrote:
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

Or use the open pragma:

use open IO => ':raw';



perldoc open



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.



Relevant Pages

  • Re: How do I parse certain "bits" out of bytes?
    ... > The wonderful thing about Perl is that it's forgiving enough and ... I find your response to Josef Moellers extremely disturbing. ... Sinan Unur ...
    (comp.lang.perl.misc)
  • Re: [FR/EN] faire un tableau / to make a table
    ... >> Josef Moellers wrote: ... >>> prerequisite for proper solutions. ... then pointing people at the FAQ list is OK. ... > didn't post any code that is proper Perl), ...
    (comp.lang.perl.misc)
  • Re: String Parsing
    ... Josef Moellers wrote: ... > Dan wrote: ... >> I am just starting to learn some parsing techniques in Perl.. ... > up with a regular expression matching a valid sentence in modern English ...
    (comp.lang.perl.misc)
  • Re: Generate HTML from a Windows Network Share
    ... bear with me as I am very much a newbie when it comes to perl. ... Josef Moellers wrote: ...
    (comp.lang.perl.misc)
  • Re: how to write a "od -bc" like function?
    ... jck11 wrote: ... Could any one give me a direction to write a function to match the unix-like ... John ... Perl isn't a toolbox, but a small machine shop where you ...
    (comp.lang.perl.misc)