Hi all,

one construct that keeps infuriating me in Perl 5 is when I’m
spelling out an explicit list where I want to include particular
elements only under certain circumstances, ie.

    $foo, $bar, $baz, $quux

but $baz should only be part of the list when $wibble is true.

In Perl 5, I can express this using one of two ways: the Looks
Like Java way and the Looks Like Linenoise way.

    my @list = ( $foo, $bar );
    push @list, $baz if $wibble;
    push @list, $quux;
    @list

    # or

    $foo, $bar, ( $wibble ? $baz : () ), $quux

There are other ways too, but all of them are either worse or
colossally worse.

Is there a construct in Perl 6 to express this more immediately?
Something along the lines of the following would seem ideal:

    $foo, $bar, ( $baz if $wibble ), $quux

Regards,
-- 
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;

Reply via email to