I'm able to tell that there are no syntax errors or compile-time warnings in your program, and I can see that it requires two input files, but I don't happen to have a file called "torah.cod" on my system, and there's no clue about what needs to be in a file called "temp.txt", so there's not much more I can do for you.
Maybe you could reduce the code to a shorter version that can demonstrate the problem, and post that along with just enough sample data so we can run it and see what the problem is.
You do seem to be doing some simple things in very complicated, bizarre ways, as in this part of the "enc()" sub that reads from "temp.txt" (I fixed the indenting a bit):
This reads a line of data from the file, then seeks to a byte offset that starts at 0 and increments on each iteration. Then, having done that seek, read one byte, and end up with two characters (in @lets) that are the hex digits for the high and low nibbles of the single byte you've just read, process those two letters, then do another full-line read (which starts at the byte following the one returned by "read(...)".open (DAT, "$file") || die "$!\n"; while (<DAT>) { seek(DAT, $cc, 0); read(DAT, $tmpR, 1); $tmpR = sprintf("%02x", ord($tmpR)); my @lets = split(//, $tmpR); $data = process($lets[0]); $data = process($lets[1]); print hex($lets[1].$lets[0])." KEY\n"; $cc++; } close(DAT);
Okay, in some sense that actually does work. But what a lot of confusion and extra effort -- it ends up as one iteration of the while loop for every byte in the file, and the number of times each byte is read from the file is equal to the average line length times 2 -- when you really just need to read the data once, like this:
I'm still puzzled why you bother assigning the return value from the "process()" sub to $data, but never use it for anything.while (<DATA>) { for my $char ( split // ) { my @lets = split //, sprintf("%02x",ord($char)); process( $_ ) for ( @lets ); print ord( $char ), " KEY\n"; } }
There's probably a lot more confusion in the OP code, and it's not just a matter of hashes. Good luck -- if you can put together a coherent question, try posting that as a reply in this thread (or start a new thread), then maybe someone here can help.
In reply to Re: Hash confusion ?!
by graff
in thread Hash confusion ?!
by thenetfreaker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |