in reply to undef and "x" operator

If it did work, it would be (((undef) x 5), $hic) =, since ()x is a different operator than x, and the former is what you would want. But it doesn't in fact work:
$ perl -we'(((undef) x 5), $foo) = 1..6; print $foo' Can't modify repeat (x) in list assignment at -e line 1, near "6;"

Replies are listed 'Best First'.
Re^2: undef and "x" operator (@!, slice, x)
by tye (Sage) on Aug 10, 2006 at 06:38 UTC
    #!/usr/bin/perl -w use strict; ( @![(0)x5], my $x )= split /-/, "a-b-c-d-e-f-g-h-i-j"; # (undef)x5, # @![1..5], # @{[]}[(0)x5], print "\$x=($x)\n"; __END__ $x=(f)

    Note that no extra keystrokes are required. (: You can golf off one keystroke at the expense of more memory consumed. Update: For two or three extra keystrokes you can avoid damaging the important global @! array.

    Yes, if I got code from someone that used this, I would indeed shoot them.

    - tye