[Kde-perl] Method returning non-scalar

Ashley Winters jahqueel at yahoo.com
Mon Nov 22 21:32:44 CET 2004


--- Ole Christensen <Ole.Christensen at web.de> wrote:
> Is this the way it is meant to be?

Umm... it's certainly not a _good_ thing. PerlQt does some voodoo with
method calls which seems to be flattening your array. Sorry about that.
I'd rather it get fixed than documented, but I'm in no position to do
either... :(

Ashley Winters
 

> -->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.
> _______________________________________________
> Kde-perl mailing list
> Kde-perl at kde.org
> https://mail.kde.org/mailman/listinfo/kde-perl
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Kde-perl mailing list