Code Comments
Programming Forum and web based access to our favorite programming groups.I am trying to write a program that reads multiple files and prints out the
number of occurrences of n-length byte sequences across these files. the
value of n must be specified on the command-line.
Since I'll be dealing with binary files, I want the ASCII codes of the
characters printed out.
e.g. for n=2 and the following 3 files, contents shown as integers,
f1 = {33, 84, 55}, f2 = {84, 55, 12}, f3 = {33, 84, 55}
I want output like this:
3 84 55
2 33 84
I'll be dealing with files up to about one megabyte in size. Efficiency is
not critical, and it does not matter, say, if a length-2 sequence is a
substring of a length-3, or a more frequently occurring sequence. Values of
n will not go above 10.
Post Follow-up to this messageC3 <> wrote:
> I am trying to write a program that reads multiple files and prints out th
e
> number of occurrences of n-length byte sequences across these files. the
> value of n must be specified on the command-line.
>
> Since I'll be dealing with binary files,
perldoc -f binmode
> I want the ASCII codes of the
> characters printed out.
Huh?
If it is a text file, then it contains ASCII codes.
If it is a binary file, then it may contain some other encoding.
Anyway,
perldoc -f chr
perldoc -f ord
> e.g. for n=2 and the following 3 files, contents shown as integers,
>
> f1 = {33, 84, 55}, f2 = {84, 55, 12}, f3 = {33, 84, 55}
>
> I want output like this:
> 3 84 55
> 2 33 84
>
> I'll be dealing with files up to about one megabyte in size. Efficiency is
> not critical, and it does not matter, say, if a length-2 sequence is a
> substring of a length-3, or a more frequently occurring sequence. Values o
f
> n will not go above 10.
Did you mean to ask a question?
What is it that you need help with?
Are you asking for someone to write a program to your specification
for you? It kind of sounds that way...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Post Follow-up to this message"C3" <_> wrote in message
news:415ac218$0$20582$afc38c87@news.optusnet.com.au...
> I am trying to write a program that reads multiple files and prints
out the
> number of occurrences of n-length byte sequences across these files.
the
> value of n must be specified on the command-line.
>
> Since I'll be dealing with binary files, I want the ASCII codes of the
> characters printed out.
>
> e.g. for n=2 and the following 3 files, contents shown as integers,
>
> f1 = {33, 84, 55}, f2 = {84, 55, 12}, f3 = {33, 84, 55}
>
> I want output like this:
> 3 84 55
> 2 33 84
>
> I'll be dealing with files up to about one megabyte in size.
Efficiency is
> not critical, and it does not matter, say, if a length-2 sequence is a
> substring of a length-3, or a more frequently occurring sequence.
Values of
> n will not go above 10.
Do you realize that no where in here did you ask a question? What is it
you need help with? What part are you stuck on? What have you tried so
far, and how did your attempt fail to work correctly?
Paul Lalli
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.