Method returning non-scalar
Ole Christensen <[email protected]> Mon, 22 Nov 2004 11:58:12 +0100
| Newsgroups | gmane.comp.kde.devel.perl |
|---|---|
| Message-ID | <[email protected]> |
Is this the way it is meant to be?
-->8-- snip --
use strict;
use warnings;
package Test;
use Qt;
use Qt::isa qw (Qt::Object);
sub a
{
my @a = ( "Hi", "there" );
return @a;
}
1;
package main;
use Test;
my $x = Test ();
my @a = $x -> a ();
printf "size=%d\n", scalar (@a);
printf "contents=<%s>\n", $a [0];
-->8-- snip --
The output of the above script is:
size=1
contents=<2>
Seems as if the return statement of sub a is forced into scalar context
somehow. If this is the intended behavior of PerlQt, it should be
documented somewhere (in bold capitals ;-) - I could not find anything
on this. Returning a hash does not work as expected neither. I am using
version 3.008 with perl v5.8.2.
Cheers, Ole.