I have hard time of understanding “use constant”. I do not understand why place
the “+” in front of constant variable. See the code below. In the for loop, It
adds “+” (+kAWSAccessKeyId,). In the new function call, it adds the “+”
(+RequestSignatureHelper::kAWSAccessKeyId => myAWSId). I read the perldoc of
“use constant”. But, no clue. Can someone explain what it mean? Or point me any
books or URLs I can read. I got the code below from some samples. If this
mailing list is not the proper place to ask this question, please tell me which
mailing list is best for this question. Thanks.
use constant kAWSAccessKeyId => 'AWSAccessKeyId';
use constant kAWSSecretKey => 'AWSSecretKey';
use constant kEndPoint => 'EndPoint';
use constant kRequestMethod => 'RequestMethod';
use constant kRequestUri => 'RequestUri';
sub new {
my $self = {};
......
for (+kAWSAccessKeyId, +kAWSSecretKey, +kRequestMethod, +kRequestUri) {
$self->{$_} = $args{$_}
};
......
$self->{+kRequestMethod}
......
}
my $helper = new RequestSignatureHelper (
+RequestSignatureHelper::kAWSAccessKeyId => myAWSId,
+RequestSignatureHelper::kAWSSecretKey => myAWSSecret,
+RequestSignatureHelper::kEndPoint => myEndPoint,
);