[Spread-users] Spread.pm

Theo E. Schlossnagle jesus at cnds.jhu.edu
Mon Dec 11 14:54:43 EST 2000

Sure, this is a perl oddity I guess.

If in perl you write:
($a, $b) = (1, 'Testing') || die "broke";
print "($a, $b)\n";

This yields: "(Testing, )"

Programming Perl Version 2, pg 47.:
"In the scalar context, the value of a list literal is value of the final
element as with the C comma operator..."

This means that the SP_connect command below results in a ($mbox,
'private_name'), but as it is used in the ||'ed expression with die, it is
considered to be just 'private_name'.  Then, you $mbox variable will contain
'private_name' instead of the Spread mailbox.  Also, the left sid eof the
assignment needs to be a list.

You are absolutely right about the anon hash thing, I will fix it in the next

the correct code should be:

my($mbox, $pname) = SP_connect( {
	'spread_name' => 4803,
	'private_name' => 'user', } );
|| die "Count not connect to local Spread daemon";
SP_join($mbox, 'CacheExp') || die "Could not join CacheExp: $sperrno";

Of course you can compact this to one line if you like, but if you are going
to test the truth value of an assignment of a list to a list, you need to
parenthesize like this:
(($mbox, $pname) = SP_connect(...))[0] || die "Couldn't connect: $sperrno";

Also, if you have no desire to know the private name returned from spread,
then you can leave off the $pname above, but make sure that the lvavlue of the
assignment is a list:
my($mbox) = ....

Hope this helps!

Andreas Dembach wrote:
> When I try to join a group, I'm getting a "Illegal Session" error. Why?
> This is the code:
> my $mbox = SP_connect( {
>     'spread_name' => '4803',
>     'private_name' => 'user',
>                 } ) || die "Could not connect to local Spread daemon:
> $!";
> # (BTW: This is wrong in the Spread.pm Perl-doc, parameters are supplied
> as anon-hash?)

I will fix this... Thanks!

> # I want to join the group "CacheExp"
> SP_join($mbox, 'CacheExp') || die "join:  $sperrno";
> this returns:
> "join:  Illegal Session at blib/lib/Base/Cache.pm line 48."

Theo Schlossnagle
1024D/A8EBCF8F/13BD 8C08 6BE2 629A 527E  2DC2 72C2 AD05 A8EB CF8F
2047R/33131B65/71 F7 95 64 49 76 5D BA  3D 90 B9 9F BE 27 24 E7

More information about the Spread-users mailing list