in reply to Perl hex substraction

So, what code have you written, and how does it fail to produce the output you want?

Replies are listed 'Best First'.
Re^2: Perl hex substraction
by inkubus (Initiate) on Feb 15, 2011 at 12:40 UTC
    The problem is I don't know how to do it :)
    I have a file with all those hex numbers like I said: 4d 2c 07 2c 77 b3 77 b3 74 81 9d 59 9d 5f 5a 9e 50 94 4e 8a 4e 8a 4e 8c 43 3c 28 1f 1d 5a 3b fe 3a f1 59 c0 9d f3 54 e2 b2 82 da 68 c1 9b ef bf 9d 59 92 a0 2a 6d 29 ed 29 ed 29 ed 29 ed 29 ed 20 e4 13"
    The "decrypted" result of the file is every hex number is the result of substracting from itself the next hex number.

      How would you do it without a computer? What part of the task do you have difficulties with?

        Ok, without computer.
        I have a sentence with numbers like (let's forget about hex):
        50 40 30 12 8 4 2
        I know this is some for of an encrypted message, and to get the message decoded every number must be substracted the next one from it:
        50 - 40 = 10 40 - 30 = 10 30 - 12 = 18 12 - 8 = 4 8 - 4 = 4 4 - 2 = 2 2 - 0 = 2
        So my result, my decoded sentence would be:
        10 10 18 4 4 2 2
        Let's say I have these hex numbers in a list or array:
        4d 2c 07 2c 77
        Every number in this array should be substracted from it the next one to it like:
        4d - 2c = 21
        so I get my result. My solved problem is that from this array I get the result of every number bring the output of substracting the next one from itself and print the result instead the original one.
      inkubus:

      Based on your nodes -- above and below -- I suspect you really, really need to read On asking for help and How do I post a question effectively?.

      In fact, reading the next few sentences may illuminate your quest:

      You'll get better answers here if you show that you've made some legitimate effort to solve your own problem. IOW, show us some code and explain how it fails and what error messages and warnings you see. And if you know nothing about programing, at least answer questions like Corion's -- write up a (structured) little list of the steps by which you could solve your problem with pencil and paper (for a liberal definition of "pencil and paper").

      The above answer doesn't do that. But the balance of your interactions in this thread might have gone better had you answered something like this:

      1. Subtract the second number from the first; save the difference somewhere
      2. Subtract the third number from the second; save the difference...
      3. and so on... until...
      4. Subtract ZERO from the last number and save the difference (or, phrased another way, 'simply save the last number').

      That's a simple-minded (and only partial) algorithm to address your request; translating that to code in any language is (just) a matter of matering the language.

      And we're here to help when some aspect of the language stumps you... but we're not here to write your code.