in reply to ... for (@_) x= 2;

x= , the repetition assignment operator, only works on scalars.

So you can do:

my $str = 'ab'; $str x= 2; print $str; # 'abab'

You don't say what you want as output, but maybe you are looking for:
#!/usr/bin/perl use warnings; use strict; $\ = $/; @_ = ( 'a' .. 'b' ) x 2; print for @_;
Output:
a b a b
edit: show example of repetition assignment on a scalar
The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: ... for (@_) x= 2;
by rsFalse (Chaplain) on Dec 28, 2015 at 21:27 UTC
    Yes, firstly, I wanted so for an output, but later I found that behaviours are interesting with using 'x=' operator :) . I experimented if I can multiply the array in 'for' sentence with using 'x='.

      Just in case this is not obvious, map tends to produce a more consistent solution in these situations:

      perl -le'print map $_ x=2, ("a" .. "f")'

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)