> [returning values from a sub?]

As other posters have said, just return a list
of some sort. Note that stuff gets flattened.
So if you do:

    sub flat {
        $foo = '1';
        @bar = (2, 3);
        $baz['4'} = 5;
        return $foo, @bar, %baz, ['qux', 'waldo']
    }

    @list = flat;

@list should contain 6 entries, effectively:

    ('1', 2, 3, '4', 5, ['qux', 'waldo'])

If you want to create some data structure and
maintain its structure on returning it, then return
a reference to the structure instead. As you can
see, that's what happened with the anonymous
array at the end (the qux waldo thing).

----

Sometimes "auto flattening" or whatever you want
to call it is wonderful, other times its inconvenient.

It looks like when auto flattening applies may
change in perl6, but that's a couple years off.

Reply via email to