Help with unfamiliar 'use' syntax

J

J Krugman

I came across the following code snippet in the documentation for
the Perl module SOAP::Lite:

use SOAP::Lite +autodispatch =>

uri => 'http://www.soaplite.com/Temperatures',
proxy => 'http://services.soaplite.com/temper.cgi';

I know that '=>' is equivalent to ',' (except that '=>' somehow
turns the preceding token into a literal string), but what about
the '+' before autodispatch? And what about the comma-separated
list that follows it? I can see how 'uri' and 'proxy' could be
subs exported by SOAP::Lite, but this couldn't be the case something
like '+autodispatch' or 'http://www.soaplite.com/Temperatures'
since these strings are not a valid Perl identifiers.

I've looked for answers to these questions in various manpages
(SOAP::Lite, Exporter, import, use, perlmod) without any luck.
Any help would be much appreciated.

jill
 
A

Anno Siegel

J Krugman said:
I came across the following code snippet in the documentation for
the Perl module SOAP::Lite:

use SOAP::Lite +autodispatch =>

uri => 'http://www.soaplite.com/Temperatures',
proxy => 'http://services.soaplite.com/temper.cgi';

I know that '=>' is equivalent to ',' (except that '=>' somehow
turns the preceding token into a literal string),

So far, so good.
but what about
the '+' before autodispatch?

Textually it is completely ignored. It can be used to guide the Perl
parser around certain ambiguities (see unary "+" in "perldoc perlop"),
but I don't think it is needed here.
And what about the comma-separated
list that follows it? I can see how 'uri' and 'proxy' could be
subs exported by SOAP::Lite, but this couldn't be the case something
like '+autodispatch' or 'http://www.soaplite.com/Temperatures'
since these strings are not a valid Perl identifiers.

Modules are free to do whatever they please with the arguments given
to "use". Exportation is only a kind of default behavior. Without
looking at the module and its documentation, there's no way of telling.

Anno
 
J

J Krugman

Textually it is completely ignored.

Do you mean that the argument that the import method actually sees
is the string 'autodispatch', and not the string '+autodispatch'?

jill
 
A

Anno Siegel

J Krugman said:
In <[email protected]>



Do you mean that the argument that the import method actually sees
is the string 'autodispatch', and not the string '+autodispatch'?

That is indeed what I mean. Try this:

perl -le 'print +autodispatch => " woohoo"'

As noted, I don't think it does anything useful in the use-statement
and shouldn't be there.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,369
Latest member
FTMZ

Latest Threads

Top