bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: adding value to hash
by Corion (Patriarch) on Sep 05, 2019 at 13:05 UTC

    Why don't you have this line at the top of your program?

    use strict;

    Having this at the top of your program lets Perl help you by pointing out simple mistypings of variable names and variable types.

      Why are you still reacting to this guy? Ignore him. Eventually he will go away.


      holli

      You can lead your users to water, but alas, you cannot drown them.
        I should have read comments before approving this question. So ashamed :(
      A reply falls below the community's threshold of quality. You may see it by logging in.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: adding value to hash
by haj (Vicar) on Sep 05, 2019 at 15:32 UTC

    I reckon that you didn't have time to read the books I recommended recently because the code still shows an embarrassing list of problems. Well, maybe you're in a lot of time trouble. But seriously: Writing so much bad code costs you a lot of time.

    • You didn't use strict; nor use warnings;, as several monks have recommended several times. Ignoring such advice will slow you down and reduce the willingness of others to help you. You might already have experienced that.
    • $data isn't %data. use strict; would have told you that, and perldata can teach you how to do it right. Heed the advice of shmem and read perldata.
    • You are calculating a digital hash signature over a string like HASH(0x55614c602278), only that the number varies on every program run and there's no chance that the recipient will ever accept any of these signatures (but since you don't add it to the correct hash anyway, this doesn't matter).

    Before you demonstrate some progress in your skills, I think it makes no sense to explain the concepts of serialization and encoding to you. Getting these right is necessary if you want to create signatures which can be actually validated by the recipient of your form.

    Good luck!

Re: adding value to hash
by shmem (Chancellor) on Sep 05, 2019 at 13:17 UTC
    and this works

    No, this not works:

    my $data = {key => "THIS: "}; my $val = "HI THIS WORKS"; $data{key} .= $val; print "$data{key}"; __END__ HI THIS WORKS

    Why? cuz $data (SCALAR, may hold an anonymous hash) and %data (HASH) are different variables.

    Read the perldata manual page. Seriously:

    Read perldata.

    update:

    Reading perldata is not a waste of time. It saves you a lot of puzzling and doubts for time to come. Not reading it in turn wastes your and our time.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re: adding value to hash
by jcb (Parson) on Sep 06, 2019 at 02:08 UTC
    1. You are not telling us which modules you are using, so I have no idea what ->www_form_urlencode expects as input or even what it actually does.
    2. Does the API want the signature calculated with an empty Signature value or none at all? Which of these does your code do?
    3. Read The Fine Article: HMAC — what are the inputs HMAC requires? What is the output that it produces?
    4. Read The Fine Manual: Digest::SHA — your code is not signing the request with your key, or with any key for that matter.
    5. Read The Fine Manual: perldata and perldsc — what are you "signing" and what are you printing?
    6. use strict; — you have made a trivial error that use strict; will catch; I will not tell you what it is because Perl will tell you if you use strict;. use strict;!