Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: backslash found where operator expected at

by jmc (Initiate)
on May 06, 2021 at 20:56 UTC ( [id://11132180]=note: print w/replies, xml ) Need Help??


in reply to Re: backslash found where operator expected at
in thread backslash found where operator expected at

Sorry for hijacking the thread, my issue is on the SES::call_ses side. If I shift $self I get an error about an empty hash for %$opts, if I don't shift $self it works. This works:
sub call_ses { my $params = shift; my $opts = shift; %opts = %$opts; %params = %$params; my $endpoint_name = $endpoint; }
This doesn't:
sub call_ses { my $self = shift; my $params = shift; my $opts = shift; %opts = %$opts; <-- Line 559 %params = %$params; my $endpoint_name = $self->AWS_endpoint; }
Can't use an undefined value as a HASH reference at /usr/share/perl5/vendor_perl/SES.pm line 559 (#1) (F) A value used as either a hard reference or a symbolic referenc +e must be a defined value. This helps to delurk some insidious errors. Uncaught exception from user code: Can't use an undefined value as a HASH reference at /usr/share +/perl5/vendor_perl/SES.pm line 559. SES::call_ses('HASH(0x243cc00)', 'HASH(0x26a2138)') called at +/opt/aws/apitools/ses/bin/ses-get-stats.pl line 168
Should I abandon $self and just call the subs like I did in the working version? Thanks to the Monastery for all the years of saving my butt as I stumbled through PERL.

Replies are listed 'Best First'.
Re^3: backslash found where operator expected at
by haj (Vicar) on May 06, 2021 at 21:33 UTC

    $self as the first parameter of a subroutine is required if - and only if - the subroutine is called as an object or class method, and the name "self" is just a convention for the object or class the method operates on. You did not provide the code how you're calling call_ses and the only reference I found for your module is that aws-apitools have been deprecated as of 2015. Perhaps you might want to have a look for CPAN modules which provide an interface to SES, like e.g. Net::AWS::SES or Paws::SES?

      Apologies, I should have noted the code being used to call call_ses is the same code as in the original post. I am looking at modules but rewriting this isn't really an option, it's a legacy system that is failing now due to the AWS signature version change from 3 to 4. I'm just trying to get it to send the Signature V4 header instead of the V3.
Re^3: backslash found where operator expected at
by AnomalousMonk (Archbishop) on May 06, 2021 at 21:58 UTC

    Further to haj's reply ...

    According to the code examples posted so far in this thread, SES::call_ses does not appear to be a method of the SES class, so assigning to a $self variable, which is, by convention, usually used to denote an object reference to or the class name of a class method, makes no sense.

    In the invocation
        my ($response_code, $response_content) = SES::call_ses \%params, \%opts;
    \%params is not a bless-ed reference (i.e., an object reference) of any kind, so don't treat it as such in a call to $self->AWS_endpoint in the

    sub call_ses { my $self = shift; ... my $endpoint_name = $self->AWS_endpoint; }
    function.

    SES::call_ses seems to be an ordinary subroutine defined in the SES package. This subroutine does not seem to be exported, so it must be invoked via the fully-qualified SES::call_ses syntax. According to the error message, this subroutine was called with two arguments, so shifting three arguments off of the @_ argument array will leave someone holding an undefined bag. Don't do that.


    Give a man a fish:  <%-{-{-{-<

      Thanks Haj for the breakdown.
Re^3: backslash found where operator expected at
by Anonymous Monk on May 07, 2021 at 15:03 UTC
    Thanks to the Monastery for all the years of saving my butt

    Welcome back, jmccall! ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132180]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found